pad-iso97971.js 1018 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. ;(function (root, factory, undef) {
  2. if (typeof exports === "object") {
  3. // CommonJS
  4. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  5. } else if (typeof define === "function" && define.amd) {
  6. // AMD
  7. define(["./core", "./cipher-core"], factory);
  8. } else {
  9. // Global (browser)
  10. factory(root.CryptoJS);
  11. }
  12. }(this, function (CryptoJS) {
  13. /**
  14. * ISO/IEC 9797-1 Padding Method 2.
  15. */
  16. CryptoJS.pad.Iso97971 = {
  17. pad: function (data, blockSize) {
  18. // Add 0x80 byte
  19. data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
  20. // Zero pad the rest
  21. CryptoJS.pad.ZeroPadding.pad(data, blockSize);
  22. },
  23. unpad: function (data) {
  24. // Remove zero padding
  25. CryptoJS.pad.ZeroPadding.unpad(data);
  26. // Remove one more byte -- the 0x80 byte
  27. data.sigBytes--;
  28. }
  29. };
  30. return CryptoJS.pad.Iso97971;
  31. }));