C# Класс StopGuessing.EncryptionPrimitives.Encryption

Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

DecryptAesCbc() публичный статический Метод

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.
Результат byte[]

DecryptAesCbcEncryptedEcPrivateKey() публичный статический Метод

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.
Результат System.Security.Cryptography.ECDiffieHellmanCng

DecryptAesCbcEncryptedPrivateKey() публичный статический Метод

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.
Результат IPrivateKey

DecryptAescbcutf8() публичный статический Метод

public static DecryptAescbcutf8 ( byte ciphertext, byte key, byte iv = null, bool checkAndRemoveHmac = false ) : string
ciphertext byte
key byte
iv byte
checkAndRemoveHmac bool
Результат string

EncryptAesCbc() публичный статический Метод

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.
Результат byte[]

EncryptAesCbc() публичный статический Метод

public static EncryptAesCbc ( string plainText, byte key, byte iv = null, bool addHmac = false ) : byte[]
plainText string
key byte
iv byte
addHmac bool
Результат byte[]

EncryptEcPrivateKeyWithAesCbc() публичный статический Метод

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.
Результат byte[]

EncryptPrivateKeyWithAesCbc() публичный статический Метод

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.
Результат byte[]

GenerateNewPrivateKey() публичный статический Метод

public static GenerateNewPrivateKey ( ) : IPrivateKey
Результат IPrivateKey

GetPublicKeyFromByteArray() публичный статический Метод

public static GetPublicKeyFromByteArray ( byte publicKeyAsByteArray ) : IPublicKey
publicKeyAsByteArray byte
Результат IPublicKey

KeyGenFromPwd() публичный статический Метод

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.
Результат byte[]