aes_icm_ossl.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. * aes_icm_ossl.c
  3. *
  4. * AES Integer Counter Mode
  5. *
  6. * John A. Foley
  7. * Cisco Systems, Inc.
  8. *
  9. * 2/24/2012: This module was modified to use CiscoSSL for AES counter
  10. * mode. Eddy Lem contributed the code to allow this.
  11. *
  12. * 12/20/2012: Added support for AES-192 and AES-256.
  13. */
  14. /*
  15. *
  16. * Copyright (c) 2013-2017, Cisco Systems, Inc.
  17. * All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms, with or without
  20. * modification, are permitted provided that the following conditions
  21. * are met:
  22. *
  23. * Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. *
  26. * Redistributions in binary form must reproduce the above
  27. * copyright notice, this list of conditions and the following
  28. * disclaimer in the documentation and/or other materials provided
  29. * with the distribution.
  30. *
  31. * Neither the name of the Cisco Systems, Inc. nor the names of its
  32. * contributors may be used to endorse or promote products derived
  33. * from this software without specific prior written permission.
  34. *
  35. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  36. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  37. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  38. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  39. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  40. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  41. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  42. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46. * OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. */
  49. #ifdef HAVE_CONFIG_H
  50. #include <config.h>
  51. #endif
  52. #include <openssl/evp.h>
  53. #include "aes_icm_ext.h"
  54. #include "crypto_types.h"
  55. #include "err.h" /* for srtp_debug */
  56. #include "alloc.h"
  57. #include "cipher_types.h"
  58. srtp_debug_module_t srtp_mod_aes_icm = {
  59. 0, /* debugging is off by default */
  60. "aes icm ossl" /* printable module name */
  61. };
  62. /*
  63. * integer counter mode works as follows:
  64. *
  65. * 16 bits
  66. * <----->
  67. * +------+------+------+------+------+------+------+------+
  68. * | nonce | packet index | ctr |---+
  69. * +------+------+------+------+------+------+------+------+ |
  70. * |
  71. * +------+------+------+------+------+------+------+------+ v
  72. * | salt |000000|->(+)
  73. * +------+------+------+------+------+------+------+------+ |
  74. * |
  75. * +---------+
  76. * | encrypt |
  77. * +---------+
  78. * |
  79. * +------+------+------+------+------+------+------+------+ |
  80. * | keystream block |<--+
  81. * +------+------+------+------+------+------+------+------+
  82. *
  83. * All fields are big-endian
  84. *
  85. * ctr is the block counter, which increments from zero for
  86. * each packet (16 bits wide)
  87. *
  88. * packet index is distinct for each packet (48 bits wide)
  89. *
  90. * nonce can be distinct across many uses of the same key, or
  91. * can be a fixed value per key, or can be per-packet randomness
  92. * (64 bits)
  93. *
  94. */
  95. /*
  96. * This function allocates a new instance of this crypto engine.
  97. * The key_len parameter should be one of 30, 38, or 46 for
  98. * AES-128, AES-192, and AES-256 respectively. Note, this key_len
  99. * value is inflated, as it also accounts for the 112 bit salt
  100. * value. The tlen argument is for the AEAD tag length, which
  101. * isn't used in counter mode.
  102. */
  103. static srtp_err_status_t srtp_aes_icm_openssl_alloc(srtp_cipher_t **c,
  104. int key_len,
  105. int tlen)
  106. {
  107. srtp_aes_icm_ctx_t *icm;
  108. debug_print(srtp_mod_aes_icm, "allocating cipher with key length %d",
  109. key_len);
  110. /*
  111. * Verify the key_len is valid for one of: AES-128/192/256
  112. */
  113. if (key_len != SRTP_AES_ICM_128_KEY_LEN_WSALT &&
  114. key_len != SRTP_AES_ICM_192_KEY_LEN_WSALT &&
  115. key_len != SRTP_AES_ICM_256_KEY_LEN_WSALT) {
  116. return srtp_err_status_bad_param;
  117. }
  118. /* allocate memory a cipher of type aes_icm */
  119. *c = (srtp_cipher_t *)srtp_crypto_alloc(sizeof(srtp_cipher_t));
  120. if (*c == NULL) {
  121. return srtp_err_status_alloc_fail;
  122. }
  123. icm = (srtp_aes_icm_ctx_t *)srtp_crypto_alloc(sizeof(srtp_aes_icm_ctx_t));
  124. if (icm == NULL) {
  125. srtp_crypto_free(*c);
  126. *c = NULL;
  127. return srtp_err_status_alloc_fail;
  128. }
  129. icm->ctx = EVP_CIPHER_CTX_new();
  130. if (icm->ctx == NULL) {
  131. srtp_crypto_free(icm);
  132. srtp_crypto_free(*c);
  133. *c = NULL;
  134. return srtp_err_status_alloc_fail;
  135. }
  136. /* set pointers */
  137. (*c)->state = icm;
  138. /* setup cipher parameters */
  139. switch (key_len) {
  140. case SRTP_AES_ICM_128_KEY_LEN_WSALT:
  141. (*c)->algorithm = SRTP_AES_ICM_128;
  142. (*c)->type = &srtp_aes_icm_128;
  143. icm->key_size = SRTP_AES_128_KEY_LEN;
  144. break;
  145. case SRTP_AES_ICM_192_KEY_LEN_WSALT:
  146. (*c)->algorithm = SRTP_AES_ICM_192;
  147. (*c)->type = &srtp_aes_icm_192;
  148. icm->key_size = SRTP_AES_192_KEY_LEN;
  149. break;
  150. case SRTP_AES_ICM_256_KEY_LEN_WSALT:
  151. (*c)->algorithm = SRTP_AES_ICM_256;
  152. (*c)->type = &srtp_aes_icm_256;
  153. icm->key_size = SRTP_AES_256_KEY_LEN;
  154. break;
  155. }
  156. /* set key size */
  157. (*c)->key_len = key_len;
  158. return srtp_err_status_ok;
  159. }
  160. /*
  161. * This function deallocates an instance of this engine
  162. */
  163. static srtp_err_status_t srtp_aes_icm_openssl_dealloc(srtp_cipher_t *c)
  164. {
  165. srtp_aes_icm_ctx_t *ctx;
  166. if (c == NULL) {
  167. return srtp_err_status_bad_param;
  168. }
  169. /*
  170. * Free the EVP context
  171. */
  172. ctx = (srtp_aes_icm_ctx_t *)c->state;
  173. if (ctx != NULL) {
  174. EVP_CIPHER_CTX_free(ctx->ctx);
  175. /* zeroize the key material */
  176. octet_string_set_to_zero(ctx, sizeof(srtp_aes_icm_ctx_t));
  177. srtp_crypto_free(ctx);
  178. }
  179. /* free memory */
  180. srtp_crypto_free(c);
  181. return srtp_err_status_ok;
  182. }
  183. /*
  184. * aes_icm_openssl_context_init(...) initializes the aes_icm_context
  185. * using the value in key[].
  186. *
  187. * the key is the secret key
  188. *
  189. * the salt is unpredictable (but not necessarily secret) data which
  190. * randomizes the starting point in the keystream
  191. */
  192. static srtp_err_status_t srtp_aes_icm_openssl_context_init(void *cv,
  193. const uint8_t *key)
  194. {
  195. srtp_aes_icm_ctx_t *c = (srtp_aes_icm_ctx_t *)cv;
  196. const EVP_CIPHER *evp;
  197. /*
  198. * set counter and initial values to 'offset' value, being careful not to
  199. * go past the end of the key buffer
  200. */
  201. v128_set_to_zero(&c->counter);
  202. v128_set_to_zero(&c->offset);
  203. memcpy(&c->counter, key + c->key_size, SRTP_SALT_LEN);
  204. memcpy(&c->offset, key + c->key_size, SRTP_SALT_LEN);
  205. /* force last two octets of the offset to zero (for srtp compatibility) */
  206. c->offset.v8[SRTP_SALT_LEN] = c->offset.v8[SRTP_SALT_LEN + 1] = 0;
  207. c->counter.v8[SRTP_SALT_LEN] = c->counter.v8[SRTP_SALT_LEN + 1] = 0;
  208. debug_print(srtp_mod_aes_icm, "key: %s",
  209. srtp_octet_string_hex_string(key, c->key_size));
  210. debug_print(srtp_mod_aes_icm, "offset: %s", v128_hex_string(&c->offset));
  211. switch (c->key_size) {
  212. case SRTP_AES_256_KEY_LEN:
  213. evp = EVP_aes_256_ctr();
  214. break;
  215. case SRTP_AES_192_KEY_LEN:
  216. evp = EVP_aes_192_ctr();
  217. break;
  218. case SRTP_AES_128_KEY_LEN:
  219. evp = EVP_aes_128_ctr();
  220. break;
  221. default:
  222. return srtp_err_status_bad_param;
  223. break;
  224. }
  225. EVP_CIPHER_CTX_cleanup(c->ctx);
  226. if (!EVP_EncryptInit_ex(c->ctx, evp, NULL, key, NULL)) {
  227. return srtp_err_status_fail;
  228. } else {
  229. return srtp_err_status_ok;
  230. }
  231. return srtp_err_status_ok;
  232. }
  233. /*
  234. * aes_icm_set_iv(c, iv) sets the counter value to the exor of iv with
  235. * the offset
  236. */
  237. static srtp_err_status_t srtp_aes_icm_openssl_set_iv(
  238. void *cv,
  239. uint8_t *iv,
  240. srtp_cipher_direction_t dir)
  241. {
  242. srtp_aes_icm_ctx_t *c = (srtp_aes_icm_ctx_t *)cv;
  243. v128_t nonce;
  244. /* set nonce (for alignment) */
  245. v128_copy_octet_string(&nonce, iv);
  246. debug_print(srtp_mod_aes_icm, "setting iv: %s", v128_hex_string(&nonce));
  247. v128_xor(&c->counter, &c->offset, &nonce);
  248. debug_print(srtp_mod_aes_icm, "set_counter: %s",
  249. v128_hex_string(&c->counter));
  250. if (!EVP_EncryptInit_ex(c->ctx, NULL, NULL, NULL, c->counter.v8)) {
  251. return srtp_err_status_fail;
  252. } else {
  253. return srtp_err_status_ok;
  254. }
  255. }
  256. /*
  257. * This function encrypts a buffer using AES CTR mode
  258. *
  259. * Parameters:
  260. * c Crypto context
  261. * buf data to encrypt
  262. * enc_len length of encrypt buffer
  263. */
  264. static srtp_err_status_t srtp_aes_icm_openssl_encrypt(void *cv,
  265. unsigned char *buf,
  266. unsigned int *enc_len)
  267. {
  268. srtp_aes_icm_ctx_t *c = (srtp_aes_icm_ctx_t *)cv;
  269. int len = 0;
  270. debug_print(srtp_mod_aes_icm, "rs0: %s", v128_hex_string(&c->counter));
  271. if (!EVP_EncryptUpdate(c->ctx, buf, &len, buf, *enc_len)) {
  272. return srtp_err_status_cipher_fail;
  273. }
  274. *enc_len = len;
  275. if (!EVP_EncryptFinal_ex(c->ctx, buf + len, &len)) {
  276. return srtp_err_status_cipher_fail;
  277. }
  278. *enc_len += len;
  279. return srtp_err_status_ok;
  280. }
  281. /*
  282. * Name of this crypto engine
  283. */
  284. static const char srtp_aes_icm_128_openssl_description[] =
  285. "AES-128 counter mode using openssl";
  286. static const char srtp_aes_icm_192_openssl_description[] =
  287. "AES-192 counter mode using openssl";
  288. static const char srtp_aes_icm_256_openssl_description[] =
  289. "AES-256 counter mode using openssl";
  290. /*
  291. * KAT values for AES self-test. These
  292. * values came from the legacy libsrtp code.
  293. */
  294. /* clang-format off */
  295. static const uint8_t srtp_aes_icm_128_test_case_0_key[SRTP_AES_ICM_128_KEY_LEN_WSALT] = {
  296. 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
  297. 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
  298. 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
  299. 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd
  300. };
  301. /* clang-format on */
  302. /* clang-format off */
  303. static uint8_t srtp_aes_icm_128_test_case_0_nonce[16] = {
  304. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  305. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  306. };
  307. /* clang-format on */
  308. /* clang-format off */
  309. static const uint8_t srtp_aes_icm_128_test_case_0_plaintext[32] = {
  310. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  311. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  312. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  313. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  314. };
  315. /* clang-format on */
  316. /* clang-format off */
  317. static const uint8_t srtp_aes_icm_128_test_case_0_ciphertext[32] = {
  318. 0xe0, 0x3e, 0xad, 0x09, 0x35, 0xc9, 0x5e, 0x80,
  319. 0xe1, 0x66, 0xb1, 0x6d, 0xd9, 0x2b, 0x4e, 0xb4,
  320. 0xd2, 0x35, 0x13, 0x16, 0x2b, 0x02, 0xd0, 0xf7,
  321. 0x2a, 0x43, 0xa2, 0xfe, 0x4a, 0x5f, 0x97, 0xab
  322. };
  323. /* clang-format on */
  324. static const srtp_cipher_test_case_t srtp_aes_icm_128_test_case_0 = {
  325. SRTP_AES_ICM_128_KEY_LEN_WSALT, /* octets in key */
  326. srtp_aes_icm_128_test_case_0_key, /* key */
  327. srtp_aes_icm_128_test_case_0_nonce, /* packet index */
  328. 32, /* octets in plaintext */
  329. srtp_aes_icm_128_test_case_0_plaintext, /* plaintext */
  330. 32, /* octets in ciphertext */
  331. srtp_aes_icm_128_test_case_0_ciphertext, /* ciphertext */
  332. 0, /* */
  333. NULL, /* */
  334. 0, /* */
  335. NULL /* pointer to next testcase */
  336. };
  337. /*
  338. * KAT values for AES-192-CTR self-test. These
  339. * values came from section 7 of RFC 6188.
  340. */
  341. /* clang-format off */
  342. static const uint8_t srtp_aes_icm_192_test_case_0_key[SRTP_AES_ICM_192_KEY_LEN_WSALT] = {
  343. 0xea, 0xb2, 0x34, 0x76, 0x4e, 0x51, 0x7b, 0x2d,
  344. 0x3d, 0x16, 0x0d, 0x58, 0x7d, 0x8c, 0x86, 0x21,
  345. 0x97, 0x40, 0xf6, 0x5f, 0x99, 0xb6, 0xbc, 0xf7,
  346. 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
  347. 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd
  348. };
  349. /* clang-format on */
  350. /* clang-format off */
  351. static uint8_t srtp_aes_icm_192_test_case_0_nonce[16] = {
  352. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  353. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  354. };
  355. /* clang-format on */
  356. /* clang-format off */
  357. static const uint8_t srtp_aes_icm_192_test_case_0_plaintext[32] = {
  358. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  359. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  360. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  361. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  362. };
  363. /* clang-format on */
  364. /* clang-format off */
  365. static const uint8_t srtp_aes_icm_192_test_case_0_ciphertext[32] = {
  366. 0x35, 0x09, 0x6c, 0xba, 0x46, 0x10, 0x02, 0x8d,
  367. 0xc1, 0xb5, 0x75, 0x03, 0x80, 0x4c, 0xe3, 0x7c,
  368. 0x5d, 0xe9, 0x86, 0x29, 0x1d, 0xcc, 0xe1, 0x61,
  369. 0xd5, 0x16, 0x5e, 0xc4, 0x56, 0x8f, 0x5c, 0x9a
  370. };
  371. /* clang-format on */
  372. static const srtp_cipher_test_case_t srtp_aes_icm_192_test_case_0 = {
  373. SRTP_AES_ICM_192_KEY_LEN_WSALT, /* octets in key */
  374. srtp_aes_icm_192_test_case_0_key, /* key */
  375. srtp_aes_icm_192_test_case_0_nonce, /* packet index */
  376. 32, /* octets in plaintext */
  377. srtp_aes_icm_192_test_case_0_plaintext, /* plaintext */
  378. 32, /* octets in ciphertext */
  379. srtp_aes_icm_192_test_case_0_ciphertext, /* ciphertext */
  380. 0, /* */
  381. NULL, /* */
  382. 0, /* */
  383. NULL /* pointer to next testcase */
  384. };
  385. /*
  386. * KAT values for AES-256-CTR self-test. These
  387. * values came from section 7 of RFC 6188.
  388. */
  389. /* clang-format off */
  390. static const uint8_t srtp_aes_icm_256_test_case_0_key[SRTP_AES_ICM_256_KEY_LEN_WSALT] = {
  391. 0x57, 0xf8, 0x2f, 0xe3, 0x61, 0x3f, 0xd1, 0x70,
  392. 0xa8, 0x5e, 0xc9, 0x3c, 0x40, 0xb1, 0xf0, 0x92,
  393. 0x2e, 0xc4, 0xcb, 0x0d, 0xc0, 0x25, 0xb5, 0x82,
  394. 0x72, 0x14, 0x7c, 0xc4, 0x38, 0x94, 0x4a, 0x98,
  395. 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
  396. 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd
  397. };
  398. /* clang-format on */
  399. /* clang-format off */
  400. static uint8_t srtp_aes_icm_256_test_case_0_nonce[16] = {
  401. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  402. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  403. };
  404. /* clang-format on */
  405. /* clang-format off */
  406. static const uint8_t srtp_aes_icm_256_test_case_0_plaintext[32] = {
  407. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  408. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  409. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  410. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  411. };
  412. /* clang-format on */
  413. /* clang-format off */
  414. static const uint8_t srtp_aes_icm_256_test_case_0_ciphertext[32] = {
  415. 0x92, 0xbd, 0xd2, 0x8a, 0x93, 0xc3, 0xf5, 0x25,
  416. 0x11, 0xc6, 0x77, 0xd0, 0x8b, 0x55, 0x15, 0xa4,
  417. 0x9d, 0xa7, 0x1b, 0x23, 0x78, 0xa8, 0x54, 0xf6,
  418. 0x70, 0x50, 0x75, 0x6d, 0xed, 0x16, 0x5b, 0xac
  419. };
  420. /* clang-format on */
  421. static const srtp_cipher_test_case_t srtp_aes_icm_256_test_case_0 = {
  422. SRTP_AES_ICM_256_KEY_LEN_WSALT, /* octets in key */
  423. srtp_aes_icm_256_test_case_0_key, /* key */
  424. srtp_aes_icm_256_test_case_0_nonce, /* packet index */
  425. 32, /* octets in plaintext */
  426. srtp_aes_icm_256_test_case_0_plaintext, /* plaintext */
  427. 32, /* octets in ciphertext */
  428. srtp_aes_icm_256_test_case_0_ciphertext, /* ciphertext */
  429. 0, /* */
  430. NULL, /* */
  431. 0, /* */
  432. NULL /* pointer to next testcase */
  433. };
  434. /*
  435. * This is the function table for this crypto engine.
  436. * note: the encrypt function is identical to the decrypt function
  437. */
  438. const srtp_cipher_type_t srtp_aes_icm_128 = {
  439. srtp_aes_icm_openssl_alloc, /* */
  440. srtp_aes_icm_openssl_dealloc, /* */
  441. srtp_aes_icm_openssl_context_init, /* */
  442. 0, /* set_aad */
  443. srtp_aes_icm_openssl_encrypt, /* */
  444. srtp_aes_icm_openssl_encrypt, /* */
  445. srtp_aes_icm_openssl_set_iv, /* */
  446. 0, /* get_tag */
  447. srtp_aes_icm_128_openssl_description, /* */
  448. &srtp_aes_icm_128_test_case_0, /* */
  449. SRTP_AES_ICM_128 /* */
  450. };
  451. /*
  452. * This is the function table for this crypto engine.
  453. * note: the encrypt function is identical to the decrypt function
  454. */
  455. const srtp_cipher_type_t srtp_aes_icm_192 = {
  456. srtp_aes_icm_openssl_alloc, /* */
  457. srtp_aes_icm_openssl_dealloc, /* */
  458. srtp_aes_icm_openssl_context_init, /* */
  459. 0, /* set_aad */
  460. srtp_aes_icm_openssl_encrypt, /* */
  461. srtp_aes_icm_openssl_encrypt, /* */
  462. srtp_aes_icm_openssl_set_iv, /* */
  463. 0, /* get_tag */
  464. srtp_aes_icm_192_openssl_description, /* */
  465. &srtp_aes_icm_192_test_case_0, /* */
  466. SRTP_AES_ICM_192 /* */
  467. };
  468. /*
  469. * This is the function table for this crypto engine.
  470. * note: the encrypt function is identical to the decrypt function
  471. */
  472. const srtp_cipher_type_t srtp_aes_icm_256 = {
  473. srtp_aes_icm_openssl_alloc, /* */
  474. srtp_aes_icm_openssl_dealloc, /* */
  475. srtp_aes_icm_openssl_context_init, /* */
  476. 0, /* set_aad */
  477. srtp_aes_icm_openssl_encrypt, /* */
  478. srtp_aes_icm_openssl_encrypt, /* */
  479. srtp_aes_icm_openssl_set_iv, /* */
  480. 0, /* get_tag */
  481. srtp_aes_icm_256_openssl_description, /* */
  482. &srtp_aes_icm_256_test_case_0, /* */
  483. SRTP_AES_ICM_256 /* */
  484. };