aes_icm_nss.c 19 KB

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