src/crypto/eax.js
async function(plaintext, nonce, adata) {
      const [
        omacNonce,
        omacAdata
      ] = await Promise.all([
        omac(zero, nonce),
        omac(one, adata)
      ]);
      const ciphered = await ctr(plaintext, omacNonce);
      const omacCiphered = await omac(two, ciphered);
      const tag = omacCiphered; // Assumes that omac(*).length === tagLength.
      for (let i = 0; i < tagLength; i++) {
        tag[i] ^= omacAdata[i] ^ omacNonce[i];
      }
      return util.concatUint8Array([ciphered, tag]);
    }
async function(plaintext, nonce, adata) {
      const [
        omacNonce,
        omacAdata
      ] = await Promise.all([
        omac(zero, nonce),
        omac(one, adata)
      ]);
      const ciphered = await ctr(plaintext, omacNonce);
      const omacCiphered = await omac(two, ciphered);
      const tag = omacCiphered; // Assumes that omac(*).length === tagLength.
      for (let i = 0; i < tagLength; i++) {
        tag[i] ^= omacAdata[i] ^ omacNonce[i];
      }
      return util.concatUint8Array([ciphered, tag]);
    }
async function ( plaintext , nonce , adata ) { const [ omacNonce , omacAdata ] = await Promise . all ( [ omac ( zero , nonce ) , omac ( one , adata ) ] ) ; const ciphered = await ctr ( plaintext , omacNonce ) ; const omacCiphered = await omac ( two , ciphered ) ; const tag = omacCiphered ; // Assumes that omac(*).length === tagLength. for ( let i = 0 ; i < tagLength ; i ++ ) { tag [ i ] ^= omacAdata [ i ] ^ omacNonce [ i ] ; } return util . concatUint8Array ( [ ciphered , tag ] ) ; }
Encrypt plaintext input.
@param  {Uint8Array} plaintext   The cleartext input to be encrypted
@param  {Uint8Array} nonce       The nonce (16 bytes)
@param  {Uint8Array} adata       Associated data to sign
@returns {Promise<Uint8Array>}    The ciphertext output
Encrypt plaintext input .