C# Class SebWindowsClient.CryptographyUtils.AESThenHMAC

Class for encrypting and decrypting with AES and HMAC, compatible with RNCryptor on Mac OS X and iOS.
Datei anzeigen Open project: SafeExamBrowser/seb-win Class Usage Examples

Public Properties

Property Type Description
BlockBitSize int
Iterations int
KeyBitSize int
MinPasswordLength int
SaltBitSize int

Public Methods

Method Description
NewKey ( ) : byte[]

Helper that generates a random key on each call.

SimpleDecrypt ( byte encryptedMessage, byte cryptKey, byte authKey, int nonSecretPayloadLength ) : byte[]
SimpleDecrypt ( string encryptedMessage, byte cryptKey, byte authKey, int nonSecretPayloadLength ) : string

Simple Authentication (HMAC) then Decryption (AES) for a secrets UTF8 Message.

SimpleDecryptWithPassword ( byte encryptedMessage, string password, int nonSecretPayloadLength ) : byte[]
SimpleDecryptWithPassword ( string encryptedMessage, string password, int nonSecretPayloadLength ) : string

Simple Authentication (HMAC) and then Descryption (AES) of a UTF8 Message using keys derived from a password (PBKDF2).

Significantly less secure than using random binary keys.

SimpleEncrypt ( byte secretMessage, byte cryptKey, byte authKey, byte nonSecretPayload = null ) : byte[]
SimpleEncrypt ( string secretMessage, byte cryptKey, byte authKey, byte nonSecretPayload = null ) : string

Simple Encryption (AES) then Authentication (HMAC) for a UTF8 Message.

Adds overhead of (Optional-Payload + BlockSize(16) + Message-Padded-To-Blocksize + HMac-Tag(32)) * 1.33 Base64

SimpleEncryptWithPassword ( byte secretMessage, string password, byte nonSecretPayload = null ) : byte[]
SimpleEncryptWithPassword ( string secretMessage, string password, byte nonSecretPayload = null ) : string

Simple Encryption (AES) then Authentication (HMAC) of a UTF8 message using Keys derived from a Password (PBKDF2).

Significantly less secure than using random binary keys. Adds additional non secret payload for key generation parameters.

Method Details

NewKey() public static method

Helper that generates a random key on each call.
public static NewKey ( ) : byte[]
return byte[]

SimpleDecrypt() public static method

public static SimpleDecrypt ( byte encryptedMessage, byte cryptKey, byte authKey, int nonSecretPayloadLength ) : byte[]
encryptedMessage byte
cryptKey byte
authKey byte
nonSecretPayloadLength int
return byte[]

SimpleDecrypt() public static method

Simple Authentication (HMAC) then Decryption (AES) for a secrets UTF8 Message.
Encrypted Message Required!;encryptedMessage
public static SimpleDecrypt ( string encryptedMessage, byte cryptKey, byte authKey, int nonSecretPayloadLength ) : string
encryptedMessage string The encrypted message.
cryptKey byte The crypt key.
authKey byte The auth key.
nonSecretPayloadLength int Length of the non secret payload.
return string

SimpleDecryptWithPassword() public static method

public static SimpleDecryptWithPassword ( byte encryptedMessage, string password, int nonSecretPayloadLength ) : byte[]
encryptedMessage byte
password string
nonSecretPayloadLength int
return byte[]

SimpleDecryptWithPassword() public static method

Simple Authentication (HMAC) and then Descryption (AES) of a UTF8 Message using keys derived from a password (PBKDF2).
Significantly less secure than using random binary keys.
Encrypted Message Required!;encryptedMessage
public static SimpleDecryptWithPassword ( string encryptedMessage, string password, int nonSecretPayloadLength ) : string
encryptedMessage string The encrypted message.
password string The password.
nonSecretPayloadLength int Length of the non secret payload.
return string

SimpleEncrypt() public static method

public static SimpleEncrypt ( byte secretMessage, byte cryptKey, byte authKey, byte nonSecretPayload = null ) : byte[]
secretMessage byte
cryptKey byte
authKey byte
nonSecretPayload byte
return byte[]

SimpleEncrypt() public static method

Simple Encryption (AES) then Authentication (HMAC) for a UTF8 Message.
Adds overhead of (Optional-Payload + BlockSize(16) + Message-Padded-To-Blocksize + HMac-Tag(32)) * 1.33 Base64
Secret Message Required!;secretMessage
public static SimpleEncrypt ( string secretMessage, byte cryptKey, byte authKey, byte nonSecretPayload = null ) : string
secretMessage string The secret message.
cryptKey byte The crypt key.
authKey byte The auth key.
nonSecretPayload byte (Optional) Non-Secret Payload.
return string

SimpleEncryptWithPassword() public static method

public static SimpleEncryptWithPassword ( byte secretMessage, string password, byte nonSecretPayload = null ) : byte[]
secretMessage byte
password string
nonSecretPayload byte
return byte[]

SimpleEncryptWithPassword() public static method

Simple Encryption (AES) then Authentication (HMAC) of a UTF8 message using Keys derived from a Password (PBKDF2).
Significantly less secure than using random binary keys. Adds additional non secret payload for key generation parameters.
password
public static SimpleEncryptWithPassword ( string secretMessage, string password, byte nonSecretPayload = null ) : string
secretMessage string The secret message.
password string The password.
nonSecretPayload byte The non secret payload.
return string

Property Details

BlockBitSize public_oe static_oe property

public static int BlockBitSize
return int

Iterations public_oe static_oe property

public static int Iterations
return int

KeyBitSize public_oe static_oe property

public static int KeyBitSize
return int

MinPasswordLength public_oe static_oe property

public static int MinPasswordLength
return int

SaltBitSize public_oe static_oe property

public static int SaltBitSize
return int