Example #1
0
        public AesCcm(ReadOnlySpan <byte> key)
        {
            ThrowIfNotSupported();

            AesAEAD.CheckKeySize(key.Length);
            ImportKey(key);
        }
Example #2
0
 private void EncryptInternal(
     ReadOnlySpan <byte> nonce,
     ReadOnlySpan <byte> plaintext,
     Span <byte> ciphertext,
     Span <byte> tag,
     ReadOnlySpan <byte> associatedData = default)
 {
     AesAEAD.Encrypt(s_aesCcm, _keyHandle, nonce, associatedData, plaintext, ciphertext, tag);
 }
Example #3
0
 private void DecryptInternal(
     ReadOnlySpan <byte> nonce,
     ReadOnlySpan <byte> ciphertext,
     ReadOnlySpan <byte> tag,
     Span <byte> plaintext,
     ReadOnlySpan <byte> associatedData = default)
 {
     AesAEAD.Decrypt(s_aesGcm, _keyHandle, nonce, associatedData, ciphertext, tag, plaintext, clearPlaintextOnFailure: true);
 }
Example #4
0
        public AesCcm(byte[] key)
        {
            ThrowIfNotSupported();

            ArgumentNullException.ThrowIfNull(key);

            AesAEAD.CheckKeySize(key.Length);
            ImportKey(key);
        }
Example #5
0
 private void DecryptInternal(
     ReadOnlySpan <byte> nonce,
     ReadOnlySpan <byte> ciphertext,
     ReadOnlySpan <byte> tag,
     Span <byte> plaintext,
     ReadOnlySpan <byte> associatedData = default)
 {
     // BCrypt implementation of CCM clears plaintext for you on failure
     AesAEAD.Decrypt(s_aesCcm, _keyHandle, nonce, associatedData, ciphertext, tag, plaintext, clearPlaintextOnFailure: false);
 }
Example #6
0
        public AesGcm(byte[] key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            AesAEAD.CheckKeySize(key.Length * 8);
            ImportKey(key);
        }
Example #7
0
        public AesCcm(byte[] key)
        {
            ThrowIfNotSupported();

            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            AesAEAD.CheckKeySize(key.Length);
            ImportKey(key);
        }
Example #8
0
 public void Decrypt(byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = null)
 {
     AesAEAD.CheckArgumentsForNull(nonce, plaintext, ciphertext, tag);
     Decrypt((ReadOnlySpan <byte>)nonce, ciphertext, tag, plaintext, associatedData);
 }
Example #9
0
 public AesGcm(ReadOnlySpan <byte> key)
 {
     AesAEAD.CheckKeySize(key.Length * 8);
     ImportKey(key);
 }