You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cipher.c 551B

123456789101112131415161718192021222324
  1. #include <stdint.h>
  2. #include <errno.h>
  3. #include <gpxe/crypto.h>
  4. int cipher_encrypt ( struct crypto_algorithm *crypto,
  5. void *ctx, const void *src, void *dst,
  6. size_t len ) {
  7. if ( ( len & ( crypto->blocksize - 1 ) ) ) {
  8. return -EINVAL;
  9. }
  10. crypto->encode ( ctx, src, dst, len );
  11. return 0;
  12. }
  13. int cipher_decrypt ( struct crypto_algorithm *crypto,
  14. void *ctx, const void *src, void *dst,
  15. size_t len ) {
  16. if ( ( len & ( crypto->blocksize - 1 ) ) ) {
  17. return -EINVAL;
  18. }
  19. crypto->decode ( ctx, src, dst, len );
  20. return 0;
  21. }