blockcipher.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2012 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Interface definition of a block cipher. A block cipher is a
  16. * pair of algorithms that implement encryption and decryption of input bytes.
  17. *
  18. * @see http://en.wikipedia.org/wiki/Block_cipher
  19. *
  20. * @author nnaze@google.com (Nathan Naze)
  21. */
  22. goog.provide('goog.crypt.BlockCipher');
  23. /**
  24. * Interface definition for a block cipher.
  25. * @interface
  26. */
  27. goog.crypt.BlockCipher = function() {};
  28. /**
  29. * Block size, in bytes.
  30. * @type {number}
  31. * @const
  32. * @public
  33. */
  34. goog.crypt.BlockCipher.prototype.BLOCK_SIZE;
  35. /**
  36. * Encrypt a plaintext block. The implementation may expect (and assert)
  37. * a particular block length.
  38. * @param {!Array<number>|!Uint8Array} input Plaintext array of input bytes.
  39. * @return {!Array<number>} Encrypted ciphertext array of bytes. Should be the
  40. * same length as input.
  41. */
  42. goog.crypt.BlockCipher.prototype.encrypt;
  43. /**
  44. * Decrypt a plaintext block. The implementation may expect (and assert)
  45. * a particular block length.
  46. * @param {!Array<number>|!Uint8Array} input Ciphertext. Array of input bytes.
  47. * @return {!Array<number>} Decrypted plaintext array of bytes. Should be the
  48. * same length as input.
  49. */
  50. goog.crypt.BlockCipher.prototype.decrypt;