C# Class StopGuessing.EncryptionPrimitives.Encryption

ファイルを表示 Open project: Microsoft/StopGuessing

Public Methods

Method Description
DecryptAesCbc ( byte ciphertext, byte key, byte iv = null, bool checkAndRemoveHmac = false ) : byte[]

Decrypt a message using AES in CBC (cipher-block chaining) mode.

DecryptAesCbcEncryptedEcPrivateKey ( byte ecPrivateKeyEncryptedWithAesCbc, byte symmetricKey ) : System.Security.Cryptography.ECDiffieHellmanCng

Decrypt an EC private key that has been stored encrypted with AES CBC using a private key

DecryptAesCbcEncryptedPrivateKey ( byte privateKeyEncryptedWithAesCbc, byte symmetricKey ) : IPrivateKey

Decrypt an EC private key that has been stored encrypted with AES CBC using a private key

DecryptAescbcutf8 ( byte ciphertext, byte key, byte iv = null, bool checkAndRemoveHmac = false ) : string
EncryptAesCbc ( byte plaintext, byte key, byte iv = null, bool addHmac = false ) : byte[]

Encrypt a message using AES in CBC (cipher-block chaining) mode.

EncryptAesCbc ( string plainText, byte key, byte iv = null, bool addHmac = false ) : byte[]
EncryptEcPrivateKeyWithAesCbc ( System.Security.Cryptography.ECDiffieHellmanCng ecPrivateKey, byte symmetricKey ) : byte[]

Encrypt an EC private key with a symmetric key.

EncryptPrivateKeyWithAesCbc ( IPrivateKey privateKey, byte symmetricKey ) : byte[]

Encrypt an EC private key with a symmetric key.

GenerateNewPrivateKey ( ) : IPrivateKey
GetPublicKeyFromByteArray ( byte publicKeyAsByteArray ) : IPublicKey
KeyGenFromPwd ( string password, byte salt ) : byte[]

Generate key from hashed password. We will need to use stronger hash later.

Method Details

DecryptAesCbc() public static method

Decrypt a message using AES in CBC (cipher-block chaining) mode.
public static DecryptAesCbc ( byte ciphertext, byte key, byte iv = null, bool checkAndRemoveHmac = false ) : byte[]
ciphertext byte The message encrypted with AES in CBC mode
key byte The key used to encrypt the message
iv byte The initialization vector provided, if one was provided. If you are absolutely certain /// the key will only be used once, an IV is not necessary and zero will be used.
checkAndRemoveHmac bool Set if an HMACHSA256 was placed at the end of the plaintext before encrypting. /// The HMAC will be removed before the plaintext is returned. If the HMAC does not match, the method will throw a /// System.Security.Cryptography.CryptographicException.
return byte[]

DecryptAesCbcEncryptedEcPrivateKey() public static method

Decrypt an EC private key that has been stored encrypted with AES CBC using a private key
public static DecryptAesCbcEncryptedEcPrivateKey ( byte ecPrivateKeyEncryptedWithAesCbc, byte symmetricKey ) : System.Security.Cryptography.ECDiffieHellmanCng
ecPrivateKeyEncryptedWithAesCbc byte The EC private key encrypted with AES CBC.
symmetricKey byte The symmetric key with which to encrypt the EC key. Must be at least /// 16 bytes. Any additional bytes will be ignored.
return System.Security.Cryptography.ECDiffieHellmanCng

DecryptAesCbcEncryptedPrivateKey() public static method

Decrypt an EC private key that has been stored encrypted with AES CBC using a private key
public static DecryptAesCbcEncryptedPrivateKey ( byte privateKeyEncryptedWithAesCbc, byte symmetricKey ) : IPrivateKey
privateKeyEncryptedWithAesCbc byte The assymetric private key encrypted with AES CBC.
symmetricKey byte The symmetric key with which to encrypt the EC key. Must be at least /// 16 bytes. Any additional bytes will be ignored.
return IPrivateKey

DecryptAescbcutf8() public static method

public static DecryptAescbcutf8 ( byte ciphertext, byte key, byte iv = null, bool checkAndRemoveHmac = false ) : string
ciphertext byte
key byte
iv byte
checkAndRemoveHmac bool
return string

EncryptAesCbc() public static method

Encrypt a message using AES in CBC (cipher-block chaining) mode.
public static EncryptAesCbc ( byte plaintext, byte key, byte iv = null, bool addHmac = false ) : byte[]
plaintext byte The message (plaintext) to encrypt
key byte An AES key
iv byte The IV to use or null to use a 0 IV
addHmac bool When set, a SHA256-based HMAC (HMAC256) of 32 bytes using the same key is added to the plaintext /// before it is encrypted.
return byte[]

EncryptAesCbc() public static method

public static EncryptAesCbc ( string plainText, byte key, byte iv = null, bool addHmac = false ) : byte[]
plainText string
key byte
iv byte
addHmac bool
return byte[]

EncryptEcPrivateKeyWithAesCbc() public static method

Encrypt an EC private key with a symmetric key.
public static EncryptEcPrivateKeyWithAesCbc ( System.Security.Cryptography.ECDiffieHellmanCng ecPrivateKey, byte symmetricKey ) : byte[]
ecPrivateKey System.Security.Cryptography.ECDiffieHellmanCng The EC private key to encrypt
symmetricKey byte The symmetric key with which to encrypt the EC key. Must be at least /// 16 bytes. Any additional bytes will be ignored.
return byte[]

EncryptPrivateKeyWithAesCbc() public static method

Encrypt an EC private key with a symmetric key.
public static EncryptPrivateKeyWithAesCbc ( IPrivateKey privateKey, byte symmetricKey ) : byte[]
privateKey IPrivateKey The EC private key to encrypt
symmetricKey byte The symmetric key with which to encrypt the EC key. Must be at least /// 16 bytes. Any additional bytes will be ignored.
return byte[]

GenerateNewPrivateKey() public static method

public static GenerateNewPrivateKey ( ) : IPrivateKey
return IPrivateKey

GetPublicKeyFromByteArray() public static method

public static GetPublicKeyFromByteArray ( byte publicKeyAsByteArray ) : IPublicKey
publicKeyAsByteArray byte
return IPublicKey

KeyGenFromPwd() public static method

Generate key from hashed password. We will need to use stronger hash later.
public static KeyGenFromPwd ( string password, byte salt ) : byte[]
password string The password to hash.
salt byte The random salt given to a password to prevent cross-account cracking.
return byte[]