2
0

cm_ameth.c 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright 2010-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #include <openssl/evp.h>
  12. #include "internal/asn1_int.h"
  13. /*
  14. * CMAC "ASN1" method. This is just here to indicate the maximum CMAC output
  15. * length and to free up a CMAC key.
  16. */
  17. static int cmac_size(const EVP_PKEY *pkey)
  18. {
  19. return EVP_MAX_BLOCK_LENGTH;
  20. }
  21. static void cmac_key_free(EVP_PKEY *pkey)
  22. {
  23. EVP_MAC_CTX *cmctx = EVP_PKEY_get0(pkey);
  24. EVP_MAC_CTX_free(cmctx);
  25. }
  26. const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
  27. EVP_PKEY_CMAC,
  28. EVP_PKEY_CMAC,
  29. 0,
  30. "CMAC",
  31. "OpenSSL CMAC method",
  32. 0, 0, 0, 0,
  33. 0, 0, 0,
  34. cmac_size,
  35. 0, 0,
  36. 0, 0, 0, 0, 0, 0, 0,
  37. cmac_key_free,
  38. 0,
  39. 0, 0
  40. };