glue.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_LRW * bmx_crypto_lrw_start(int cipher, const unsigned char *IV, const unsigned char *key, int keylen, const unsigned char *tweak, int numRounds) {
  20. symmetric_LRW * lrw = malloc(sizeof(symmetric_LRW));
  21. int res = lrw_start(cipher, IV, key, keylen, tweak, numRounds, lrw);
  22. if (res != CRYPT_OK) {
  23. free(lrw);
  24. lrw = NULL;
  25. }
  26. return lrw;
  27. }
  28. int bmx_crypto_lrw_encrypt(symmetric_LRW * lrw, const unsigned char * pt, unsigned char * ct, BBUINT length) {
  29. return lrw_encrypt(pt, ct, length, lrw);
  30. }
  31. int bmx_crypto_lrw_decrypt(symmetric_LRW * lrw, const unsigned char * ct, unsigned char * pt, BBUINT length) {
  32. return lrw_decrypt(ct, pt, length, lrw);
  33. }
  34. int bmx_crypto_lrw_getiv(symmetric_LRW * lrw, unsigned char * IV, BBUINT * length) {
  35. unsigned long len;
  36. int res = lrw_getiv(IV, &len, lrw);
  37. *length = len;
  38. return res;
  39. }
  40. int bmx_crypto_lrw_setiv(symmetric_LRW * lrw, const unsigned char * IV, BBUINT length) {
  41. return lrw_setiv(IV, length, lrw);
  42. }
  43. int bmx_crypto_lrw_done(symmetric_LRW * lrw) {
  44. int res = lrw_done(lrw);
  45. free(lrw);
  46. return res;
  47. }