sjcl.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /** @fileOverview Javascript cryptography implementation.
  2. *
  3. * Crush to remove comments, shorten variable names and
  4. * generally reduce transmission size.
  5. *
  6. * @author Emily Stark
  7. * @author Mike Hamburg
  8. * @author Dan Boneh
  9. */
  10. "use strict";
  11. /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
  12. /*global document, window, escape, unescape */
  13. /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
  14. var sjcl = {
  15. /** @namespace Symmetric ciphers. */
  16. cipher: {},
  17. /** @namespace Hash functions. Right now only SHA256 is implemented. */
  18. hash: {},
  19. /** @namespace Block cipher modes of operation. */
  20. mode: {},
  21. /** @namespace Miscellaneous. HMAC and PBKDF2. */
  22. misc: {},
  23. /**
  24. * @namespace Bit array encoders and decoders.
  25. *
  26. * @description
  27. * The members of this namespace are functions which translate between
  28. * SJCL's bitArrays and other objects (usually strings). Because it
  29. * isn't always clear which direction is encoding and which is decoding,
  30. * the method names are "fromBits" and "toBits".
  31. */
  32. codec: {},
  33. /** @namespace Exceptions. */
  34. exception: {
  35. /** @class Ciphertext is corrupt. */
  36. corrupt: function(message) {
  37. this.toString = function() { return "CORRUPT: "+this.message; };
  38. this.message = message;
  39. },
  40. /** @class Invalid parameter. */
  41. invalid: function(message) {
  42. this.toString = function() { return "INVALID: "+this.message; };
  43. this.message = message;
  44. },
  45. /** @class Bug or missing feature in SJCL. */
  46. bug: function(message) {
  47. this.toString = function() { return "BUG: "+this.message; };
  48. this.message = message;
  49. },
  50. /** @class Bug or missing feature in SJCL. */
  51. notReady: function(message) {
  52. this.toString = function() { return "GENERATOR NOT READY: "+this.message; };
  53. this.message = message;
  54. }
  55. }
  56. };