private static IntPtr GetCipherType(BulkCipherType cipherType, out int keySize, out int nonceSize, out int overhead) { switch (cipherType) { case BulkCipherType.AES_128_GCM: keySize = 16; nonceSize = 12; overhead = 16; return(EVP_aes_128_gcm); case BulkCipherType.AES_256_GCM: keySize = 32; nonceSize = 12; overhead = 16; return(EVP_aes_256_gcm); case BulkCipherType.CHACHA20_POLY1305: keySize = 32; nonceSize = 12; overhead = 16; return(EVP_chacha20_poly1305); default: keySize = 0; nonceSize = 0; overhead = 0; return(IntPtr.Zero); } }
public ISymmetricalCipher GetCipherKey(BulkCipherType cipherType, OwnedMemory <byte> keyStorage) { var(keySize, ivSize, bulkCipher) = GetCipher(cipherType); var key = new OpenSslBulkCipherKey(bulkCipher, keyStorage, keySize, ivSize, 16); return(key); }
public EphemeralSessionProviderFaster(int numberOfKeys, ICryptoProvider provider, BulkCipherType cipherType, SecretSchedulePool secretPool) { _cryptoProvider = provider; _cipherType = cipherType; _keyGuid = Guid.NewGuid(); GenerateKeys(secretPool, numberOfKeys); }
public int GetKeySize(BulkCipherType cipherType) { int keySize, nonceSize, overhead; GetCipherType(cipherType, out keySize, out nonceSize, out overhead); return(keySize); }
public IBulkCipherInstance GetCipherKey(BulkCipherType cipher) { if (cipher == BulkCipherType.AES_128_GCM || cipher == BulkCipherType.AES_256_GCM) { return(new AeadBulkCipherInstance(_aesProvider, _bufferPool, cipher)); } return(null); }
public T GetCipher <T>(BulkCipherType cipherType, OwnedMemory <byte> keyStorage) where T : AeadBulkCipher, new() { var key = GetCipherKey(cipherType, keyStorage); var returnValue = new T(); returnValue.SetKey(key); return(returnValue); }
public EphemeralSessionProvider(ICryptoProvider provider, BulkCipherType cipherType, SecretSchedulePool secretPool) { _cryptoProvider = provider; _cipherType = cipherType; var keyBuffer = secretPool.GetKeyBuffer(); _key = GenerateKey(keyBuffer); _keyGuid = Guid.NewGuid(); }
public CipherSuite(ushort code, string name, BulkCipherType cipherType, HashType hashType, KeyExchangeType?keyExchange, CertificateType?certificateType, params TlsVersion[] supportedVersions) { _bulkCipherType = cipherType; _certificateType = certificateType; _code = code; _name = name; _hashType = hashType; _keyExchange = keyExchange; _supportedVersions = supportedVersions ?? new TlsVersion[0]; }
public IBulkCipherInstance GetCipherKey(BulkCipherType cipher) { int keySize, nonceSize, overhead; var type = GetCipherType(cipher, out keySize, out nonceSize, out overhead); if (type != IntPtr.Zero) { return(new AeadBulkCipherInstance(type, _bufferPool, nonceSize, keySize, overhead)); } return(null); }
public int GetKeySize(BulkCipherType cipherType) { switch (cipherType) { case BulkCipherType.AES_128_CCM: case BulkCipherType.AES_128_GCM: return(16); case BulkCipherType.AES_256_GCM: return(32); default: throw new NotImplementedException(); } }
private (int keySize, int ivSize, EVP_BulkCipher_Type bulkCipher) GetCipher(BulkCipherType cipherType) { switch (cipherType) { case BulkCipherType.AES_128_GCM: return(16, 12, EVP_aes_128_gcm); case BulkCipherType.AES_256_GCM: return(32, 12, EVP_aes_256_gcm); case BulkCipherType.CHACHA20_POLY1305: return(32, 12, EVP_chacha20_poly1305); default: throw new NotImplementedException(); } }
public abstract BulkCipherKey GetCipherKey(BulkCipherType cipherType, Memory <byte> keyStorage);
public abstract BulkCipher GetCipher <T>(BulkCipherType cipherType, ReadOnlyMemory <byte> keyStorage) where T : BulkCipher, new();
public abstract (int keySize, int ivSize) GetCipherSize(BulkCipherType cipherType);
public (int keySize, int ivSize) GetCipherSize(BulkCipherType cipherType) { var(keySize, ivSize, cipher) = GetCipher(cipherType); return(keySize, ivSize); }
internal unsafe AeadBulkCipherInstance(SafeBCryptAlgorithmHandle algo, EphemeralBufferPoolWindows bufferPool, BulkCipherType cipherType) { _bufferPool = bufferPool; _algo = algo; switch (cipherType) { case BulkCipherType.AES_128_GCM: _chainingMode = BCRYPT_CHAIN_MODE_GCM; _keyLength = 16; _iVLength = 16; _overhead = 16; break; case BulkCipherType.AES_256_GCM: _chainingMode = BCRYPT_CHAIN_MODE_GCM; _keyLength = 32; _iVLength = 16; _overhead = 16; break; default: Internal.ExceptionHelper.ThrowException(new InvalidOperationException()); return; } _keyStore = bufferPool.Rent(0); void *tmpPointer; if (!_keyStore.Memory.TryGetPointer(out tmpPointer)) { throw new InvalidOperationException("Could not get keystore pointer"); } _ivPointer = (IntPtr)tmpPointer; }