C# Class StopGuessing.EncryptionPrimitives.Encryption

Afficher le fichier Open project: Microsoft/StopGuessing

Méthodes publiques

Méthode 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 méthode

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.
Résultat byte[]

DecryptAesCbcEncryptedEcPrivateKey() public static méthode

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.
Résultat System.Security.Cryptography.ECDiffieHellmanCng

DecryptAesCbcEncryptedPrivateKey() public static méthode

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.
Résultat IPrivateKey

DecryptAescbcutf8() public static méthode

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

EncryptAesCbc() public static méthode

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.
Résultat byte[]

EncryptAesCbc() public static méthode

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

EncryptEcPrivateKeyWithAesCbc() public static méthode

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.
Résultat byte[]

EncryptPrivateKeyWithAesCbc() public static méthode

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.
Résultat byte[]

GenerateNewPrivateKey() public static méthode

public static GenerateNewPrivateKey ( ) : IPrivateKey
Résultat IPrivateKey

GetPublicKeyFromByteArray() public static méthode

public static GetPublicKeyFromByteArray ( byte publicKeyAsByteArray ) : IPublicKey
publicKeyAsByteArray byte
Résultat IPublicKey

KeyGenFromPwd() public static méthode

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.
Résultat byte[]