anubiscipher.bmx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. '
  2. ' Copyright (C) 2019-2020 Bruce A Henderson
  3. '
  4. ' This software is provided 'as-is', without any express or implied
  5. ' warranty. In no event will the authors be held liable for any damages
  6. ' arising from the use of this software.
  7. '
  8. ' Permission is granted to anyone to use this software for any purpose,
  9. ' including commercial applications, and to alter it and redistribute it
  10. ' freely, subject to the following restrictions:
  11. '
  12. ' 1. The origin of this software must not be misrepresented; you must not
  13. ' claim that you wrote the original software. If you use this software
  14. ' in a product, an acknowledgment in the product documentation would be
  15. ' appreciated but is not required.
  16. ' 2. Altered source versions must be plainly marked as such, and must not be
  17. ' misrepresented as being the original software.
  18. ' 3. This notice may not be removed or altered from any source distribution.
  19. '
  20. SuperStrict
  21. Rem
  22. bbdoc: Anubis Block Cipher.
  23. about: Anubis operates on data blocks of 128 bits, accepting keys of length 32N bits `(N = 4, ..., 10)`.
  24. It is designed as a substitution-permutation network, which bears large similarity to #AESCipher.
  25. See https://en.wikipedia.org/wiki/Anubis_(cipher)
  26. End Rem
  27. Module Crypto.AnubisCipher
  28. ModuleInfo "CC_OPTS: -DLTC_NO_TEST -DLTC_NO_FILE"
  29. ModuleInfo "CC_OPTS: -DLTC_ANUBIS"
  30. Import "common.bmx"
  31. New TAnubisCipherFactory(bmx_crypto_anubis_register())
  32. Type TAnubisCipher Extends TCipher
  33. Method KeySize:Int(key:Int) Override
  34. Return bmx_crypto_anubis_keysize(key)
  35. End Method
  36. Method Name:String() Override
  37. Return "anubis"
  38. End Method
  39. End Type
  40. Type TAnubisCipherFactory Extends TCipherFactory
  41. Method Find:TCipher(index:Int) Override
  42. If index = Self.index Then
  43. Return New TAnubisCipher(index)
  44. End If
  45. End Method
  46. End Type