You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If creating a key for hybrid cryptosystem, in my understanding the key should just be created from a cryptographic random number generator. Which is much simpler and faster.
If you want to protect data, take a look to ProtectedMemory or ProtectedData. I think to use SecureString to store an array of byte is not the idea of SecureString. And what it the benefit when the content of SecureString is unwrapped a few statements later?
The initialisation vector is part of the key. So I think you disclose information from the key. Instead of the comment "Possibly security critical" it should be fixed or thrown an exception.
I would suggest to use an authenticated encryption (AE) or authenticated encryption with associated data (AEAD) mode for AES. Take a look to System.Security.Cryptography.AesGcm
You are copying some date from one array to get your parameter for your crypto system. Maybe the Cryptographic Message Syntax is something for you, instead of invent your own message syntax.
Using RsaPkcs1
As I know, you shouldn't use PKCS1 to pad the plaintext. You could use Optimal Asymmetric Encryption Padding (OAEP) see RsaOaepSha512
"In principle, usage of this [RSA with PKCS1v1.5 padding] padding format is encouraged neither for encryption nor for signature applications" See "1.4. Handling of legacy algorithms" in BSI TR-02102-1
The text was updated successfully, but these errors were encountered:
The nuget package "Capgemini.Cauldron.Cryptography" came to my attention. With around 30k downloads I was curious and did take a look.
I really would like some feedback on my thoughts/ideas.
ZipAsBytes
Why are you try to compress data, that shouldn't be compressible? What do you want to archive?
Same samples:
Cauldron/Shared/Cauldron.Cryptography/Aes.cs
Line 121 in 6a1cf11
Cauldron/Shared/Cauldron.Cryptography/KeyMaterial.cs
Line 59 in 6a1cf11
Cauldron/Shared/Cauldron.Cryptography/KeyMaterial.cs
Line 65 in 6a1cf11
Creating a crypto key
If creating a key for hybrid cryptosystem, in my understanding the key should just be created from a cryptographic random number generator. Which is much simpler and faster.
Cauldron/Shared/Cauldron.Cryptography/RsaAes.cs
Line 113 in 6a1cf11
It would be just simpler to use for salt a cryptographic random number generator too.
Cauldron/Shared/Cauldron.Cryptography/KeyMaterial.cs
Line 121 in 6a1cf11
Use MD5 as standard hash
Why is the unsafe MD5 the standard hash? MD5 is cryptographically broken and unsuitable for further use.
Cauldron/Shared/Cauldron.Cryptography/ExtensionsCryptography.cs
Line 22 in 6a1cf11
Securing a byte array with SecureString
If you want to protect data, take a look to ProtectedMemory or ProtectedData. I think to use SecureString to store an array of byte is not the idea of SecureString. And what it the benefit when the content of SecureString is unwrapped a few statements later?
Cauldron/Shared/Cauldron.Cryptography/ExtensionsCryptography.cs
Line 101 in 6a1cf11
GC
Calling the GC is in most case a bad sign, maybe not here. But I don't how this in combination with OnDispose could help with security.
Cauldron/Shared/Cauldron.Cryptography/KeyMaterial.cs
Line 74 in 6a1cf11
Initialisation Vector
The initialisation vector is part of the key. So I think you disclose information from the key. Instead of the comment "Possibly security critical" it should be fixed or thrown an exception.
Cauldron/Shared/Cauldron.Cryptography/KeyMaterial.cs
Line 60 in 6a1cf11
Magic Numbers
The code would be easier to read if the magic numbers had descriptive variables.
For example:
Cauldron/Shared/Cauldron.Cryptography/Aes.cs
Line 118 in 6a1cf11
Cauldron/Shared/Cauldron.Cryptography/RsaAes.cs
Line 119 in 6a1cf11
Authenticated Encryption
I would suggest to use an authenticated encryption (AE) or authenticated encryption with associated data (AEAD) mode for AES. Take a look to System.Security.Cryptography.AesGcm
Cauldron/Shared/Cauldron.Cryptography/Aes.cs
Line 94 in 6a1cf11
This would break backwards combability but it maybe something for the next major version.
Random
For the Seed for Random you could just use
Guid.NewGuid().GetHashCode()
.This would reduce the complexity and you have the same result.
Cauldron/Shared/Cauldron.Randomizer/Randomizer.cs
Line 21 in 6a1cf11
Cryptographic Message Syntax
You are copying some date from one array to get your parameter for your crypto system. Maybe the Cryptographic Message Syntax is something for you, instead of invent your own message syntax.
Using RsaPkcs1
As I know, you shouldn't use PKCS1 to pad the plaintext. You could use Optimal Asymmetric Encryption Padding (OAEP) see RsaOaepSha512
"In principle, usage of this [RSA with PKCS1v1.5 padding] padding format is encouraged neither for encryption nor for signature applications" See "1.4. Handling of legacy algorithms" in BSI TR-02102-1
The text was updated successfully, but these errors were encountered: