sjcl.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Key exchange functions. Right now only SRP is implemented. */
  20. keyexchange: {},
  21. /** @namespace Block cipher modes of operation. */
  22. mode: {},
  23. /** @namespace Miscellaneous. HMAC and PBKDF2. */
  24. misc: {},
  25. /**
  26. * @namespace Bit array encoders and decoders.
  27. *
  28. * @description
  29. * The members of this namespace are functions which translate between
  30. * SJCL's bitArrays and other objects (usually strings). Because it
  31. * isn't always clear which direction is encoding and which is decoding,
  32. * the method names are "fromBits" and "toBits".
  33. */
  34. codec: {},
  35. /** @namespace Exceptions. */
  36. exception: {
  37. /** @class Ciphertext is corrupt. */
  38. corrupt: function(message) {
  39. this.toString = function() { return "CORRUPT: "+this.message; };
  40. this.message = message;
  41. },
  42. /** @class Invalid parameter. */
  43. invalid: function(message) {
  44. this.toString = function() { return "INVALID: "+this.message; };
  45. this.message = message;
  46. },
  47. /** @class Bug or missing feature in SJCL. */
  48. bug: function(message) {
  49. this.toString = function() { return "BUG: "+this.message; };
  50. this.message = message;
  51. },
  52. /** @class Bug or missing feature in SJCL. */
  53. notReady: function(message) {
  54. this.toString = function() { return "GENERATOR NOT READY: "+this.message; };
  55. this.message = message;
  56. }
  57. }
  58. };