glue.c 1.9 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_OFB * bmx_crypto_ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, int keylen, int numRounds) {
  20. symmetric_OFB * ofb = malloc(sizeof(symmetric_OFB));
  21. int res = ofb_start(cipher, IV, key, keylen, numRounds, ofb);
  22. if (res != CRYPT_OK) {
  23. free(ofb);
  24. ofb = NULL;
  25. }
  26. return ofb;
  27. }
  28. int bmx_crypto_ofb_encrypt(symmetric_OFB * ofb, const unsigned char * pt, unsigned char * ct, BBUINT length) {
  29. return ofb_encrypt(pt, ct, length, ofb);
  30. }
  31. int bmx_crypto_ofb_decrypt(symmetric_OFB * ofb, const unsigned char * ct, unsigned char * pt, BBUINT length) {
  32. return ofb_decrypt(ct, pt, length, ofb);
  33. }
  34. int bmx_crypto_ofb_getiv(symmetric_OFB * ofb, unsigned char * IV, BBUINT * length) {
  35. unsigned long len;
  36. int res = ofb_getiv(IV, &len, ofb);
  37. *length = len;
  38. return res;
  39. }
  40. int bmx_crypto_ofb_setiv(symmetric_OFB * ofb, const unsigned char * IV, BBUINT length) {
  41. return ofb_setiv(IV, length, ofb);
  42. }
  43. int bmx_crypto_ofb_done(symmetric_OFB * ofb) {
  44. int res = ofb_done(ofb);
  45. free(ofb);
  46. return res;
  47. }