2
0

cm_ameth.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2010-2016 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 <openssl/cmac.h>
  13. #include "crypto/asn1.h"
  14. /*
  15. * CMAC "ASN1" method. This is just here to indicate the maximum CMAC output
  16. * length and to free up a CMAC key.
  17. */
  18. static int cmac_size(const EVP_PKEY *pkey)
  19. {
  20. return EVP_MAX_BLOCK_LENGTH;
  21. }
  22. static void cmac_key_free(EVP_PKEY *pkey)
  23. {
  24. CMAC_CTX *cmctx = EVP_PKEY_get0(pkey);
  25. CMAC_CTX_free(cmctx);
  26. }
  27. const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
  28. EVP_PKEY_CMAC,
  29. EVP_PKEY_CMAC,
  30. 0,
  31. "CMAC",
  32. "OpenSSL CMAC method",
  33. 0, 0, 0, 0,
  34. 0, 0, 0,
  35. cmac_size,
  36. 0, 0,
  37. 0, 0, 0, 0, 0, 0, 0,
  38. cmac_key_free,
  39. 0,
  40. 0, 0
  41. };