packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prf, plaintext, iv, adata, tlen) {
    var L, out = plaintext.slice(0), tag, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(out) / 8;
    tlen = tlen || 64;
    adata = adata || [];

    if (ivl < 7) {
      throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");
    }

    // compute the length of the length
    for (L=2; L<4 && ol >>> 8*L; L++) {}
    if (L < 15 - ivl) { L = 15-ivl; }
    iv = w.clamp(iv,8*(15-L));

    // compute the tag
    tag = sjcl.mode.ccm._computeTag(prf, plaintext, iv, adata, tlen, L);

    // encrypt
    out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L);

    return w.concat(out.data, out.tag);
  }
function(prf, plaintext, iv, adata, tlen) {
    var L, out = plaintext.slice(0), tag, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(out) / 8;
    tlen = tlen || 64;
    adata = adata || [];

    if (ivl < 7) {
      throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");
    }

    // compute the length of the length
    for (L=2; L<4 && ol >>> 8*L; L++) {}
    if (L < 15 - ivl) { L = 15-ivl; }
    iv = w.clamp(iv,8*(15-L));

    // compute the tag
    tag = sjcl.mode.ccm._computeTag(prf, plaintext, iv, adata, tlen, L);

    // encrypt
    out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L);

    return w.concat(out.data, out.tag);
  }
function ( prf , plaintext , iv , adata , tlen ) { var L , out = plaintext . slice ( 0 ) , tag , w = sjcl . bitArray , ivl = w . bitLength ( iv ) / 8 , ol = w . bitLength ( out ) / 8 ; tlen = tlen || 64 ; adata = adata || [ ] ; if ( ivl < 7 ) { throw new sjcl . exception . invalid ( "ccm: iv must be at least 7 bytes" ) ; } // compute the length of the length for ( L = 2 ; L < 4 && ol >>> 8 * L ; L ++ ) { } if ( L < 15 - ivl ) { L = 15 - ivl ; } iv = w . clamp ( iv , 8 * ( 15 - L ) ) ; // compute the tag tag = sjcl . mode . ccm . _computeTag ( prf , plaintext , iv , adata , tlen , L ) ; // encrypt out = sjcl . mode . ccm . _ctrMode ( prf , out , iv , tag , tlen , L ) ; return w . concat ( out . data , out . tag ) ; }
Encrypt in CCM mode.
@static
@param {Object} prf The pseudorandom function.  It must have a block size of 16 bytes.
@param {bitArray} plaintext The plaintext data.
@param {bitArray} iv The initialization value.
@param {bitArray} [adata=[]] The authenticated data.
@param {Number} [tlen=64] the desired tag length, in bits.
@return {bitArray} The encrypted data, an array of bytes.
Encrypt in CCM mode .