glue.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. Copyright (C) 2019-2022 Bruce A Henderson
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely, subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not
  10. claim that you wrote the original software. If you use this software
  11. in a product, an acknowledgment in the product documentation would be
  12. appreciated but is not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source distribution.
  16. */
  17. #include "tomcrypt.h"
  18. #include "brl.mod/blitz.mod/blitz.h"
  19. symmetric_xts * bmx_crypto_xts_start(int cipher, const unsigned char *key1, const unsigned char *key2, int keylen, int numRounds) {
  20. symmetric_xts * xts = malloc(sizeof(symmetric_xts));
  21. int res = xts_start(cipher, key1, key2, keylen, numRounds, xts);
  22. if (res != CRYPT_OK) {
  23. free(xts);
  24. xts = NULL;
  25. }
  26. return xts;
  27. }
  28. int bmx_crypto_xts_encrypt(symmetric_xts * xts, const unsigned char * pt, BBUINT ptlength, unsigned char * ct, const unsigned char * tweak) {
  29. return xts_encrypt(pt, ptlength, ct, tweak, xts);
  30. }
  31. int bmx_crypto_xts_decrypt(symmetric_xts * xts, const unsigned char * ct, BBUINT ptlength, unsigned char * pt, const unsigned char * tweak) {
  32. return xts_decrypt(ct, ptlength, pt, tweak, xts);
  33. }
  34. int bmx_crypto_xts_done(symmetric_xts * xts) {
  35. xts_done(xts);
  36. free(xts);
  37. return 1;
  38. }