Show / Hide Table of Contents

Class SmartcryptCrypto

Extension methods for ICryptoProvider that make it much easier to implement the Smartcrypt Protocol.

Inheritance
Object
SmartcryptCrypto
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: PKWARE.Smartcrypt.Protocol
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
Type Description
Int32

Methods

DecryptV2(ICryptoProvider, String, Byte[])

Declaration
[Pure]
public static byte[] DecryptV2(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
String cipherText
Byte[] key
Returns
Type Description
Byte[]
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

DecryptV3(ICryptoProvider, String, Byte[])

Declaration
[Pure]
public static byte[] DecryptV3(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
String cipherText
Byte[] key
Returns
Type Description
Byte[]
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

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
Type Description
Byte[]
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

DecryptV5(ICryptoProvider, String, Byte[])

Declaration
[Pure]
public static byte[] DecryptV5(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
String cipherText
Byte[] key
Returns
Type Description
Byte[]
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

DecryptV6(ICryptoProvider, String, Byte[])

Declaration
[Pure]
public static byte[] DecryptV6(this ICryptoProvider cryptoProvider, string cipherText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
String cipherText
Byte[] key
Returns
Type Description
Byte[]
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

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
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

See Also
EncryptV7(ICryptoProvider, String, Byte[])

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
Type Description
String
Exceptions
Type Condition
MetaClientException

With Category of CategoryUpgrade if the data are newer than understood by this software. With Category of CategoryInternal if the data are in an invalid format.

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
Type Name Description
ICryptoProvider cryptoProvider
Byte[] plainText

A 32 byte raw AES key.

Byte[] key

The raw AES key of the user's highest KindPriv AssetKey.

Int32 keySequence

The keysequence of the user's highest KindPriv AssetKey.

Returns
Type Description
String

EncryptV4(ICryptoProvider, Byte[], Byte[])

Declaration
[Pure]
[NotNull]
public static string EncryptV4(this ICryptoProvider cryptoProvider, [NotNull] byte[] plainText, [NotNull] byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
Byte[] plainText
Byte[] key
Returns
Type Description
String

EncryptV5(ICryptoProvider, Byte[], Byte[])

Declaration
[Pure]
public static string EncryptV5(this ICryptoProvider cryptoProvider, byte[] plainText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
Byte[] plainText
Byte[] key
Returns
Type Description
String

EncryptV6(ICryptoProvider, Byte[], Byte[])

Declaration
[Pure]
public static string EncryptV6(this ICryptoProvider cryptoProvider, byte[] plainText, byte[] key)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
Byte[] plainText
Byte[] key
Returns
Type Description
String

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
DecryptV7(ICryptoProvider, String, Byte[])

GenerateKeyFromPassword(ICryptoProvider, String, String, Int32)

Declaration
[Pure]
public static byte[] GenerateKeyFromPassword(this ICryptoProvider cryptoProvider, string password, string salt, int iterations)
Parameters
Type Name Description
ICryptoProvider cryptoProvider
String password
String salt
Int32 iterations
Returns
Type Description
Byte[]

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
Type Name Description
ICryptoProvider cryptoProvider

The ICryptoProvider to use for cryptographic primitives.

Byte[] key

The RSA private key to use for signing.

String content

The data to sign.

Returns
Type Description
String

The signature with the V2 prefix.

See Also
VerifySignature(ICryptoProvider, Byte[], String, String)

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
Sign(ICryptoProvider, Byte[], String)

See Also

EncryptionTactic
SemanticEncryption
Back to top Copyright © 2018 PKWARE, Inc.