cipher_aes_ocb.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /*
  2. * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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 "cipher_aes_ocb.h"
  10. #include "internal/providercommonerr.h"
  11. #include "internal/ciphers/cipher_aead.h"
  12. #include "internal/provider_algs.h"
  13. #define AES_OCB_FLAGS AEAD_FLAGS
  14. #define OCB_DEFAULT_TAG_LEN 16
  15. #define OCB_DEFAULT_IV_LEN 12
  16. #define OCB_MIN_IV_LEN 1
  17. #define OCB_MAX_IV_LEN 15
  18. PROV_CIPHER_FUNC(int, ocb_cipher, (PROV_AES_OCB_CTX *ctx,
  19. const unsigned char *in, unsigned char *out,
  20. size_t nextblock));
  21. /* forward declarations */
  22. static OSSL_OP_cipher_encrypt_init_fn aes_ocb_einit;
  23. static OSSL_OP_cipher_decrypt_init_fn aes_ocb_dinit;
  24. static OSSL_OP_cipher_update_fn aes_ocb_block_update;
  25. static OSSL_OP_cipher_final_fn aes_ocb_block_final;
  26. static OSSL_OP_cipher_cipher_fn aes_ocb_cipher;
  27. static OSSL_OP_cipher_freectx_fn aes_ocb_freectx;
  28. static OSSL_OP_cipher_dupctx_fn aes_ocb_dupctx;
  29. static OSSL_OP_cipher_get_ctx_params_fn aes_ocb_get_ctx_params;
  30. static OSSL_OP_cipher_set_ctx_params_fn aes_ocb_set_ctx_params;
  31. /*
  32. * The following methods could be moved into PROV_AES_OCB_HW if
  33. * multiple hardware implementations are ever needed.
  34. */
  35. static ossl_inline int aes_generic_ocb_setiv(PROV_AES_OCB_CTX *ctx,
  36. const unsigned char *iv,
  37. size_t ivlen, size_t taglen)
  38. {
  39. return (CRYPTO_ocb128_setiv(&ctx->ocb, iv, ivlen, taglen) == 1);
  40. }
  41. static ossl_inline int aes_generic_ocb_setaad(PROV_AES_OCB_CTX *ctx,
  42. const unsigned char *aad,
  43. size_t alen)
  44. {
  45. return CRYPTO_ocb128_aad(&ctx->ocb, aad, alen) == 1;
  46. }
  47. static ossl_inline int aes_generic_ocb_gettag(PROV_AES_OCB_CTX *ctx,
  48. unsigned char *tag, size_t tlen)
  49. {
  50. return CRYPTO_ocb128_tag(&ctx->ocb, tag, tlen) > 0;
  51. }
  52. static ossl_inline int aes_generic_ocb_final(PROV_AES_OCB_CTX *ctx)
  53. {
  54. return (CRYPTO_ocb128_finish(&ctx->ocb, ctx->tag, ctx->taglen) == 0);
  55. }
  56. static ossl_inline void aes_generic_ocb_cleanup(PROV_AES_OCB_CTX *ctx)
  57. {
  58. CRYPTO_ocb128_cleanup(&ctx->ocb);
  59. }
  60. static ossl_inline int aes_generic_ocb_cipher(PROV_AES_OCB_CTX *ctx,
  61. const unsigned char *in,
  62. unsigned char *out, size_t len)
  63. {
  64. if (ctx->base.enc) {
  65. if (!CRYPTO_ocb128_encrypt(&ctx->ocb, in, out, len))
  66. return 0;
  67. } else {
  68. if (!CRYPTO_ocb128_decrypt(&ctx->ocb, in, out, len))
  69. return 0;
  70. }
  71. return 1;
  72. }
  73. static ossl_inline int aes_generic_ocb_copy_ctx(PROV_AES_OCB_CTX *dst,
  74. PROV_AES_OCB_CTX *src)
  75. {
  76. return (!CRYPTO_ocb128_copy_ctx(&dst->ocb, &src->ocb,
  77. &src->ksenc.ks, &src->ksdec.ks));
  78. }
  79. /*-
  80. * Provider dispatch functions
  81. */
  82. static int aes_ocb_init(void *vctx, const unsigned char *key, size_t keylen,
  83. const unsigned char *iv, size_t ivlen, int enc)
  84. {
  85. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  86. ctx->base.enc = enc;
  87. if (iv != NULL) {
  88. if (ivlen != ctx->base.ivlen) {
  89. /* IV len must be 1 to 15 */
  90. if (ivlen < OCB_MIN_IV_LEN || ivlen > OCB_MAX_IV_LEN) {
  91. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
  92. return 0;
  93. }
  94. ctx->base.ivlen = ivlen;
  95. }
  96. memcpy(ctx->base.iv, iv, ivlen);
  97. ctx->iv_state = IV_STATE_BUFFERED;
  98. }
  99. if (key != NULL) {
  100. if (keylen != ctx->base.keylen) {
  101. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
  102. return 0;
  103. }
  104. return ctx->base.hw->init(&ctx->base, key, keylen);
  105. }
  106. return 1;
  107. }
  108. static int aes_ocb_einit(void *vctx, const unsigned char *key, size_t keylen,
  109. const unsigned char *iv, size_t ivlen)
  110. {
  111. return aes_ocb_init(vctx, key, keylen, iv, ivlen, 1);
  112. }
  113. static int aes_ocb_dinit(void *vctx, const unsigned char *key, size_t keylen,
  114. const unsigned char *iv, size_t ivlen)
  115. {
  116. return aes_ocb_init(vctx, key, keylen, iv, ivlen, 0);
  117. }
  118. /*
  119. * Because of the way OCB works, both the AAD and data are buffered in the
  120. * same way. Only the last block can be a partial block.
  121. */
  122. static int aes_ocb_block_update_internal(PROV_AES_OCB_CTX *ctx,
  123. unsigned char *buf, size_t *bufsz,
  124. unsigned char *out, size_t *outl,
  125. size_t outsize, const unsigned char *in,
  126. size_t inl, OSSL_ocb_cipher_fn ciph)
  127. {
  128. size_t nextblocks = fillblock(buf, bufsz, AES_BLOCK_SIZE, &in, &inl);
  129. size_t outlint = 0;
  130. if (*bufsz == AES_BLOCK_SIZE) {
  131. if (outsize < AES_BLOCK_SIZE) {
  132. ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
  133. return 0;
  134. }
  135. if (!ciph(ctx, buf, out, AES_BLOCK_SIZE)) {
  136. ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
  137. return 0;
  138. }
  139. *bufsz = 0;
  140. outlint = AES_BLOCK_SIZE;
  141. out += AES_BLOCK_SIZE;
  142. }
  143. if (nextblocks > 0) {
  144. outlint += nextblocks;
  145. if (outsize < outlint) {
  146. ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
  147. return 0;
  148. }
  149. if (!ciph(ctx, in, out, nextblocks)) {
  150. ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
  151. return 0;
  152. }
  153. in += nextblocks;
  154. inl -= nextblocks;
  155. }
  156. if (!trailingdata(buf, bufsz, AES_BLOCK_SIZE, &in, &inl)) {
  157. /* PROVerr already called */
  158. return 0;
  159. }
  160. *outl = outlint;
  161. return inl == 0;
  162. }
  163. /* A wrapper function that has the same signature as cipher */
  164. static int cipher_updateaad(PROV_AES_OCB_CTX *ctx, const unsigned char *in,
  165. unsigned char *out, size_t len)
  166. {
  167. return aes_generic_ocb_setaad(ctx, in, len);
  168. }
  169. static int update_iv(PROV_AES_OCB_CTX *ctx)
  170. {
  171. if (ctx->iv_state == IV_STATE_FINISHED
  172. || ctx->iv_state == IV_STATE_UNINITIALISED)
  173. return 0;
  174. if (ctx->iv_state == IV_STATE_BUFFERED) {
  175. if (!aes_generic_ocb_setiv(ctx, ctx->base.iv, ctx->base.ivlen,
  176. ctx->taglen))
  177. return 0;
  178. ctx->iv_state = IV_STATE_COPIED;
  179. }
  180. return 1;
  181. }
  182. static int aes_ocb_block_update(void *vctx, unsigned char *out, size_t *outl,
  183. size_t outsize, const unsigned char *in,
  184. size_t inl)
  185. {
  186. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  187. unsigned char *buf;
  188. size_t *buflen;
  189. OSSL_ocb_cipher_fn fn;
  190. if (!ctx->key_set || !update_iv(ctx))
  191. return 0;
  192. /* Are we dealing with AAD or normal data here? */
  193. if (out == NULL) {
  194. buf = ctx->aad_buf;
  195. buflen = &ctx->aad_buf_len;
  196. fn = cipher_updateaad;
  197. } else {
  198. buf = ctx->data_buf;
  199. buflen = &ctx->data_buf_len;
  200. fn = aes_generic_ocb_cipher;
  201. }
  202. return aes_ocb_block_update_internal(ctx, buf, buflen, out, outl, outsize,
  203. in, inl, fn);
  204. }
  205. static int aes_ocb_block_final(void *vctx, unsigned char *out, size_t *outl,
  206. size_t outsize)
  207. {
  208. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  209. /* If no block_update has run then the iv still needs to be set */
  210. if (!ctx->key_set || !update_iv(ctx))
  211. return 0;
  212. /*
  213. * Empty the buffer of any partial block that we might have been provided,
  214. * both for data and AAD
  215. */
  216. *outl = 0;
  217. if (ctx->data_buf_len > 0) {
  218. if (!aes_generic_ocb_cipher(ctx, ctx->data_buf, out, ctx->data_buf_len))
  219. return 0;
  220. *outl = ctx->data_buf_len;
  221. ctx->data_buf_len = 0;
  222. }
  223. if (ctx->aad_buf_len > 0) {
  224. if (!aes_generic_ocb_setaad(ctx, ctx->aad_buf, ctx->aad_buf_len))
  225. return 0;
  226. ctx->aad_buf_len = 0;
  227. }
  228. if (ctx->base.enc) {
  229. /* If encrypting then just get the tag */
  230. if (!aes_generic_ocb_gettag(ctx, ctx->tag, ctx->taglen))
  231. return 0;
  232. } else {
  233. /* If decrypting then verify */
  234. if (ctx->taglen == 0)
  235. return 0;
  236. if (!aes_generic_ocb_final(ctx))
  237. return 0;
  238. }
  239. /* Don't reuse the IV */
  240. ctx->iv_state = IV_STATE_FINISHED;
  241. return 1;
  242. }
  243. static void *aes_ocb_newctx(void *provctx, size_t kbits, size_t blkbits,
  244. size_t ivbits, unsigned int mode, uint64_t flags)
  245. {
  246. PROV_AES_OCB_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  247. if (ctx != NULL) {
  248. cipher_generic_initkey(ctx, kbits, blkbits, ivbits, mode, flags,
  249. PROV_CIPHER_HW_aes_ocb(kbits), NULL);
  250. ctx->taglen = OCB_DEFAULT_TAG_LEN;
  251. }
  252. return ctx;
  253. }
  254. static void aes_ocb_freectx(void *vctx)
  255. {
  256. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  257. if (ctx != NULL) {
  258. aes_generic_ocb_cleanup(ctx);
  259. OPENSSL_cleanse(ctx->base.iv, sizeof(ctx->base.iv));
  260. OPENSSL_clear_free(ctx, sizeof(*ctx));
  261. }
  262. }
  263. static void *aes_ocb_dupctx(void *vctx)
  264. {
  265. PROV_AES_OCB_CTX *in = (PROV_AES_OCB_CTX *)vctx;
  266. PROV_AES_OCB_CTX *ret = OPENSSL_malloc(sizeof(*ret));
  267. if (ret == NULL) {
  268. ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
  269. return NULL;
  270. }
  271. *ret = *in;
  272. if (!aes_generic_ocb_copy_ctx(ret, in)) {
  273. OPENSSL_free(ret);
  274. ret = NULL;
  275. }
  276. return ret;
  277. }
  278. static int aes_ocb_set_ctx_params(void *vctx, const OSSL_PARAM params[])
  279. {
  280. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  281. const OSSL_PARAM *p;
  282. size_t sz;
  283. p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_TAG);
  284. if (p != NULL) {
  285. if (p->data_type != OSSL_PARAM_OCTET_STRING) {
  286. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
  287. return 0;
  288. }
  289. if (p->data == NULL) {
  290. /* Tag len must be 0 to 16 */
  291. if (p->data_size > OCB_MAX_TAG_LEN)
  292. return 0;
  293. ctx->taglen = p->data_size;
  294. } else {
  295. if (p->data_size != ctx->taglen || ctx->base.enc)
  296. return 0;
  297. memcpy(ctx->tag, p->data, p->data_size);
  298. }
  299. }
  300. p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_IVLEN);
  301. if (p != NULL) {
  302. if (!OSSL_PARAM_get_size_t(p, &sz)) {
  303. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
  304. return 0;
  305. }
  306. /* IV len must be 1 to 15 */
  307. if (sz < OCB_MIN_IV_LEN || sz > OCB_MAX_IV_LEN)
  308. return 0;
  309. ctx->base.ivlen = sz;
  310. }
  311. p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN);
  312. if (p != NULL) {
  313. size_t keylen;
  314. if (!OSSL_PARAM_get_size_t(p, &keylen)) {
  315. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
  316. return 0;
  317. }
  318. if (ctx->base.keylen != keylen) {
  319. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
  320. return 0;
  321. }
  322. }
  323. return 1;
  324. }
  325. static int aes_ocb_get_ctx_params(void *vctx, OSSL_PARAM params[])
  326. {
  327. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  328. OSSL_PARAM *p;
  329. p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IVLEN);
  330. if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.ivlen)) {
  331. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  332. return 0;
  333. }
  334. p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN);
  335. if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.keylen)) {
  336. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  337. return 0;
  338. }
  339. p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAGLEN);
  340. if (p != NULL) {
  341. if (!OSSL_PARAM_set_size_t(p, ctx->taglen)) {
  342. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  343. return 0;
  344. }
  345. }
  346. p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IV);
  347. if (p != NULL) {
  348. if (ctx->base.ivlen != p->data_size) {
  349. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
  350. return 0;
  351. }
  352. if (!OSSL_PARAM_set_octet_string(p, ctx->base.iv, ctx->base.ivlen)) {
  353. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  354. return 0;
  355. }
  356. }
  357. p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAG);
  358. if (p != NULL) {
  359. if (p->data_type != OSSL_PARAM_OCTET_STRING) {
  360. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
  361. return 0;
  362. }
  363. if (!ctx->base.enc || p->data_size != ctx->taglen) {
  364. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAGLEN);
  365. return 0;
  366. }
  367. memcpy(p->data, ctx->tag, ctx->taglen);
  368. }
  369. return 1;
  370. }
  371. static const OSSL_PARAM cipher_ocb_known_gettable_ctx_params[] = {
  372. OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
  373. OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),
  374. OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TAGLEN, NULL),
  375. OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),
  376. OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0),
  377. OSSL_PARAM_END
  378. };
  379. static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(void)
  380. {
  381. return cipher_ocb_known_gettable_ctx_params;
  382. }
  383. static const OSSL_PARAM cipher_ocb_known_settable_ctx_params[] = {
  384. OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
  385. OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_IVLEN, NULL),
  386. OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0),
  387. OSSL_PARAM_END
  388. };
  389. static const OSSL_PARAM *cipher_ocb_settable_ctx_params(void)
  390. {
  391. return cipher_ocb_known_settable_ctx_params;
  392. }
  393. static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl,
  394. size_t outsize, const unsigned char *in, size_t inl)
  395. {
  396. PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
  397. if (outsize < inl) {
  398. ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
  399. return 0;
  400. }
  401. if (!aes_generic_ocb_cipher(ctx, in, out, inl)) {
  402. ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
  403. return 0;
  404. }
  405. *outl = inl;
  406. return 1;
  407. }
  408. #define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits) \
  409. static OSSL_OP_cipher_get_params_fn aes_##kbits##_##mode##_get_params; \
  410. static int aes_##kbits##_##mode##_get_params(OSSL_PARAM params[]) \
  411. { \
  412. return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
  413. flags, kbits, blkbits, ivbits); \
  414. } \
  415. static OSSL_OP_cipher_newctx_fn aes_##kbits##_##mode##_newctx; \
  416. static void *aes_##kbits##_##mode##_newctx(void *provctx) \
  417. { \
  418. return aes_##mode##_newctx(provctx, kbits, blkbits, ivbits, \
  419. EVP_CIPH_##UCMODE##_MODE, flags); \
  420. } \
  421. const OSSL_DISPATCH aes##kbits##mode##_functions[] = { \
  422. { OSSL_FUNC_CIPHER_NEWCTX, \
  423. (void (*)(void))aes_##kbits##_##mode##_newctx }, \
  424. { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_##mode##_einit }, \
  425. { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_##mode##_dinit }, \
  426. { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_##mode##_block_update }, \
  427. { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))aes_##mode##_block_final }, \
  428. { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_ocb_cipher }, \
  429. { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_##mode##_freectx }, \
  430. { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_##mode##_dupctx }, \
  431. { OSSL_FUNC_CIPHER_GET_PARAMS, \
  432. (void (*)(void))aes_##kbits##_##mode##_get_params }, \
  433. { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \
  434. (void (*)(void))aes_##mode##_get_ctx_params }, \
  435. { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \
  436. (void (*)(void))aes_##mode##_set_ctx_params }, \
  437. { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \
  438. (void (*)(void))cipher_generic_gettable_params }, \
  439. { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \
  440. (void (*)(void))cipher_ocb_gettable_ctx_params }, \
  441. { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \
  442. (void (*)(void))cipher_ocb_settable_ctx_params }, \
  443. { 0, NULL } \
  444. }
  445. IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8);
  446. IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8);
  447. IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8);