2020-06-30 12:49:37 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
Imports System
|
|
|
|
Imports System.Security.Cryptography
|
|
|
|
|
|
|
|
Namespace MyNamespace
|
|
|
|
|
|
|
|
Public Class Class1
|
|
|
|
|
|
|
|
Public Sub Main()
|
|
|
|
|
|
|
|
Dim data As Byte() = {1, 1, 1}
|
|
|
|
|
|
|
|
Dim myRSA As RSA = RSA.Create()
|
|
|
|
Dim padding As RSAEncryptionPadding = RSAEncryptionPadding.CreateOaep(HashAlgorithmName.SHA1)
|
|
|
|
|
|
|
|
' Review all base RSA class' Encrypt/Decrypt calls
|
|
|
|
myRSA.Encrypt(data, padding) ' Sensitive
|
|
|
|
myRSA.EncryptValue(data) ' Sensitive
|
|
|
|
myRSA.Decrypt(data, padding) ' Sensitive
|
|
|
|
myRSA.DecryptValue(data) ' Sensitive
|
|
|
|
|
|
|
|
Dim myRSAC As RSACryptoServiceProvider = New RSACryptoServiceProvider()
|
|
|
|
' Review the use of any TryEncrypt/TryDecrypt And specific Encrypt/Decrypt of RSA subclasses.
|
|
|
|
myRSAC.Encrypt(data, False) ' Sensitive
|
|
|
|
myRSAC.Decrypt(data, False) ' Sensitive
|
|
|
|
|
|
|
|
Dim written As Integer
|
|
|
|
myRSAC.TryEncrypt(data, Span<byte>.Empty, padding, out written) ' Sensitive
|
|
|
|
myRSAC.TryDecrypt(data, Span<byte>.Empty, padding, out written) ' Sensitive
|
|
|
|
|
|
|
|
Dim rgbKey As Byte() = {1, 2, 3}
|
|
|
|
Dim rgbIV As Byte() = {4, 5, 6}
|
|
|
|
Dim rijn = SymmetricAlgorithm.Create()
|
|
|
|
|
|
|
|
' Review the creation of Encryptors from any SymmetricAlgorithm instance.
|
|
|
|
rijn.CreateEncryptor() ' Sensitive
|
|
|
|
rijn.CreateEncryptor(rgbKey, rgbIV) ' Sensitive
|
|
|
|
rijn.CreateDecryptor() ' Sensitive
|
|
|
|
rijn.CreateDecryptor(rgbKey, rgbIV) ' Sensitive
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Public Class MyCrypto
|
|
|
|
Inherits System.Security.Cryptography.AsymmetricAlgorithm ' Sensitive
|
|
|
|
' ...
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class MyCrypto2
|
|
|
|
Inherits System.Security.Cryptography.SymmetricAlgorithm ' Sensitive
|
|
|
|
' ...
|
|
|
|
End Class
|
|
|
|
End Class
|
|
|
|
End Namespace
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|