123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.pkcs7=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
- /*
- * pkcs7.pad
- * https://github.com/brightcove/pkcs7
- *
- * Copyright (c) 2014 Brightcove
- * Licensed under the apache2 license.
- */
- 'use strict';
- var PADDING;
- /**
- * Returns a new Uint8Array that is padded with PKCS#7 padding.
- * @param plaintext {Uint8Array} the input bytes before encryption
- * @return {Uint8Array} the padded bytes
- * @see http://tools.ietf.org/html/rfc5652
- */
- module.exports = function pad(plaintext) {
- var padding = PADDING[(plaintext.byteLength % 16) || 0],
- result = new Uint8Array(plaintext.byteLength + padding.length);
- result.set(plaintext);
- result.set(padding, plaintext.byteLength);
- return result;
- };
- // pre-define the padding values
- PADDING = [
- [16, 16, 16, 16,
- 16, 16, 16, 16,
- 16, 16, 16, 16,
- 16, 16, 16, 16],
- [15, 15, 15, 15,
- 15, 15, 15, 15,
- 15, 15, 15, 15,
- 15, 15, 15],
- [14, 14, 14, 14,
- 14, 14, 14, 14,
- 14, 14, 14, 14,
- 14, 14],
- [13, 13, 13, 13,
- 13, 13, 13, 13,
- 13, 13, 13, 13,
- 13],
- [12, 12, 12, 12,
- 12, 12, 12, 12,
- 12, 12, 12, 12],
- [11, 11, 11, 11,
- 11, 11, 11, 11,
- 11, 11, 11],
- [10, 10, 10, 10,
- 10, 10, 10, 10,
- 10, 10],
- [9, 9, 9, 9,
- 9, 9, 9, 9,
- 9],
- [8, 8, 8, 8,
- 8, 8, 8, 8],
- [7, 7, 7, 7,
- 7, 7, 7],
- [6, 6, 6, 6,
- 6, 6],
- [5, 5, 5, 5,
- 5],
- [4, 4, 4, 4],
- [3, 3, 3],
- [2, 2],
- [1]
- ];
- },{}],2:[function(_dereq_,module,exports){
- /*
- * pkcs7
- * https://github.com/brightcove/pkcs7
- *
- * Copyright (c) 2014 Brightcove
- * Licensed under the apache2 license.
- */
- 'use strict';
- exports.pad = _dereq_('./pad.js');
- exports.unpad = _dereq_('./unpad.js');
- },{"./pad.js":1,"./unpad.js":3}],3:[function(_dereq_,module,exports){
- /*
- * pkcs7.unpad
- * https://github.com/brightcove/pkcs7
- *
- * Copyright (c) 2014 Brightcove
- * Licensed under the apache2 license.
- */
- 'use strict';
- /**
- * Returns the subarray of a Uint8Array without PKCS#7 padding.
- * @param padded {Uint8Array} unencrypted bytes that have been padded
- * @return {Uint8Array} the unpadded bytes
- * @see http://tools.ietf.org/html/rfc5652
- */
- module.exports = function unpad(padded) {
- return padded.subarray(0, padded.byteLength - padded[padded.byteLength - 1]);
- };
- },{}]},{},[2])
- (2)
- });
|