Class SmartcryptCrypto
Extension methods for ICryptoProvider that make it much easier to implement the Smartcrypt
Protocol.
Inheritance
SmartcryptCrypto
Assembly: SmartcryptProtocol.dll
Syntax
public static class SmartcryptCrypto
Fields
AesKeySize
The size, in bytes, of AES keys used by Smartcrypt.
Declaration
public const int AesKeySize = 32
Field Value
Methods
DecryptV2(ICryptoProvider, String, Byte[])
Declaration
[Pure]
public static byte[] DecryptV2(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Returns
Exceptions
DecryptV3(ICryptoProvider, String, Byte[])
Declaration
[Pure]
public static byte[] DecryptV3(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Returns
Exceptions
DecryptV4(ICryptoProvider, String, Byte[])
Declaration
[Pure]
[NotNull]
public static byte[] DecryptV4(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type |
Name |
Description |
ICryptoProvider |
cryptoProvider |
|
String |
cipherText |
|
Byte[] |
key |
AES key. Will be adujsted to the correct length.
|
Returns
Exceptions
DecryptV5(ICryptoProvider, String, Byte[])
Declaration
[Pure]
public static byte[] DecryptV5(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Returns
Exceptions
DecryptV6(ICryptoProvider, String, Byte[])
Declaration
[Pure]
public static byte[] DecryptV6(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Returns
Exceptions
DecryptV7(ICryptoProvider, String, Byte[])
Decrypts using AES V7 encryption, given the cipher text and a key.
Declaration
[Pure]
public static string DecryptV7(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type |
Name |
Description |
ICryptoProvider |
cryptoProvider |
|
String |
cipherText |
A string with a V7 prefix, followed by a hexadecimal 16
byte initalization vector, and then the encrypted text.
|
Byte[] |
key |
The key used for decryption.
|
Returns
Type |
Description |
String |
The string that was originally encrypted into the cipher text.
|
Exceptions
See Also
EncryptV2(ICryptoProvider, Byte[], String)
RSA encryption. Ciphertext is Base64 encoded and gets the V2 prefix.
Declaration
[Pure]
[NotNull]
public static string EncryptV2([NotNull] this ICryptoProvider cryptoProvider, [NotNull] byte[] plainText, [NotNull] string key)
Parameters
Type |
Name |
Description |
ICryptoProvider |
cryptoProvider |
|
Byte[] |
plainText |
The content to encrypt.
|
String |
key |
An RSA public key Base64 encoded and with the V2 prefix.
|
Returns
Exceptions
EncryptV3(ICryptoProvider, Byte[], Byte[], Int32)
AES encryption of an AES key using a random IV and the provided AES key. No padding.
Declaration
[Pure]
public static string EncryptV3(this ICryptoProvider cryptoProvider, byte[] plainText, byte[] key, int keySequence)
Parameters
Returns
EncryptV4(ICryptoProvider, Byte[], Byte[])
Declaration
[Pure]
[NotNull]
public static string EncryptV4(this ICryptoProvider cryptoProvider, [NotNull] byte[] plainText, [NotNull] byte[] key)
Parameters
Returns
EncryptV5(ICryptoProvider, Byte[], Byte[])
Declaration
[Pure]
public static string EncryptV5(this ICryptoProvider cryptoProvider, byte[] plainText, byte[] key)
Parameters
Returns
EncryptV6(ICryptoProvider, Byte[], Byte[])
Declaration
[Pure]
public static string EncryptV6(this ICryptoProvider cryptoProvider, byte[] plainText, byte[] key)
Parameters
Returns
EncryptV7(ICryptoProvider, String, Byte[])
Encrypts a minimum 32 byte password using a provided key, which should come from an Asset.
If the password is not at least 32 bytes, it should be padded with null characters before
calling this method.
Declaration
[Pure]
public static string EncryptV7(this ICryptoProvider cryptoProvider, string password, byte[] key)
Parameters
Type |
Name |
Description |
ICryptoProvider |
cryptoProvider |
|
String |
password |
The 32 byte or more null-padded password.
|
Byte[] |
key |
The key coming from an AssetKey.
|
Returns
Type |
Description |
String |
A string representing the V7 encryption tactic.
|
See Also
GenerateKeyFromPassword(ICryptoProvider, String, String, Int32)
Declaration
[Pure]
public static byte[] GenerateKeyFromPassword(this ICryptoProvider cryptoProvider, string password, string salt, int iterations)
Parameters
Returns
Sign(ICryptoProvider, Byte[], String)
Performs an RSA signature of the content.
Declaration
[Pure]
public static string Sign(this ICryptoProvider cryptoProvider, byte[] key, string content)
Parameters
Returns
Type |
Description |
String |
The signature with the V2 prefix.
|
See Also
VerifySignature(ICryptoProvider, Byte[], String, String)
Verifies the integrity of data by checking the RSA signature.
Declaration
[Pure]
public static bool VerifySignature(this ICryptoProvider cryptoProvider, [NotNull] byte[] rsaPublicKey, [NotNull] string data, [NotNull] string signature)
Parameters
Type |
Name |
Description |
ICryptoProvider |
cryptoProvider |
The provider to use for cryptographic primitives.
|
Byte[] |
rsaPublicKey |
The RSA public key matching the private key used to sign the data.
|
String |
data |
The data that was signed.
|
String |
signature |
The RSA signature, with the version prefix.
|
Returns
Type |
Description |
Boolean |
true if the RSA signature checked out, otherwise false .
|
See Also
See Also