17188Smcpowers /* 27188Smcpowers * CDDL HEADER START 37188Smcpowers * 47188Smcpowers * The contents of this file are subject to the terms of the 57188Smcpowers * Common Development and Distribution License (the "License"). 67188Smcpowers * You may not use this file except in compliance with the License. 77188Smcpowers * 87188Smcpowers * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97188Smcpowers * or http://www.opensolaris.org/os/licensing. 107188Smcpowers * See the License for the specific language governing permissions 117188Smcpowers * and limitations under the License. 127188Smcpowers * 137188Smcpowers * When distributing Covered Code, include this CDDL HEADER in each 147188Smcpowers * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157188Smcpowers * If applicable, add the following below this CDDL HEADER, with the 167188Smcpowers * fields enclosed by brackets "[]" replaced with your own identifying 177188Smcpowers * information: Portions Copyright [yyyy] [name of copyright owner] 187188Smcpowers * 197188Smcpowers * CDDL HEADER END 207188Smcpowers */ 217188Smcpowers /* 228559SMark.Powers@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237188Smcpowers * Use is subject to license terms. 247188Smcpowers */ 257188Smcpowers 267188Smcpowers #ifndef _COMMON_CRYPTO_MODES_H 277188Smcpowers #define _COMMON_CRYPTO_MODES_H 287188Smcpowers 297188Smcpowers #ifdef __cplusplus 307188Smcpowers extern "C" { 317188Smcpowers #endif 327188Smcpowers 337188Smcpowers #include <sys/strsun.h> 347188Smcpowers #include <sys/systm.h> 357188Smcpowers #include <sys/sysmacros.h> 367188Smcpowers #include <sys/types.h> 377188Smcpowers #include <sys/errno.h> 387188Smcpowers #include <sys/rwlock.h> 397188Smcpowers #include <sys/kmem.h> 407188Smcpowers #include <sys/crypto/common.h> 417188Smcpowers #include <sys/crypto/impl.h> 427188Smcpowers 437188Smcpowers #define ECB_MODE 0x00000002 447188Smcpowers #define CBC_MODE 0x00000004 457188Smcpowers #define CTR_MODE 0x00000008 467188Smcpowers #define CCM_MODE 0x00000010 478005SMark.Powers@Sun.COM #define GCM_MODE 0x00000020 48*9339SMark.Powers@Sun.COM #define GMAC_MODE 0x00000040 497188Smcpowers 507188Smcpowers /* 517188Smcpowers * cc_keysched: Pointer to key schedule. 527188Smcpowers * 537188Smcpowers * cc_keysched_len: Length of the key schedule. 547188Smcpowers * 557188Smcpowers * cc_remainder: This is for residual data, i.e. data that can't 567188Smcpowers * be processed because there are too few bytes. 577188Smcpowers * Must wait until more data arrives. 587188Smcpowers * 597188Smcpowers * cc_remainder_len: Number of bytes in cc_remainder. 607188Smcpowers * 617188Smcpowers * cc_iv: Scratch buffer that sometimes contains the IV. 627188Smcpowers * 637188Smcpowers * cc_lastp: Pointer to previous block of ciphertext. 647188Smcpowers * 657188Smcpowers * cc_copy_to: Pointer to where encrypted residual data needs 667188Smcpowers * to be copied. 677188Smcpowers * 687188Smcpowers * cc_flags: PROVIDER_OWNS_KEY_SCHEDULE 697188Smcpowers * When a context is freed, it is necessary 707188Smcpowers * to know whether the key schedule was allocated 717188Smcpowers * by the caller, or internally, e.g. an init routine. 727188Smcpowers * If allocated by the latter, then it needs to be freed. 737188Smcpowers * 747188Smcpowers * ECB_MODE, CBC_MODE, CTR_MODE, or CCM_MODE 757188Smcpowers */ 767188Smcpowers struct common_ctx { 777188Smcpowers void *cc_keysched; 787188Smcpowers size_t cc_keysched_len; 797188Smcpowers uint64_t cc_iv[2]; 807188Smcpowers uint64_t cc_remainder[2]; 817188Smcpowers size_t cc_remainder_len; 827188Smcpowers uint8_t *cc_lastp; 837188Smcpowers uint8_t *cc_copy_to; 847188Smcpowers uint32_t cc_flags; 857188Smcpowers }; 867188Smcpowers 877188Smcpowers typedef struct common_ctx common_ctx_t; 887188Smcpowers 897581SMark.Powers@Sun.COM typedef struct ecb_ctx { 907581SMark.Powers@Sun.COM struct common_ctx ecb_common; 917581SMark.Powers@Sun.COM uint64_t ecb_lastblock[2]; 927581SMark.Powers@Sun.COM } ecb_ctx_t; 937581SMark.Powers@Sun.COM 947581SMark.Powers@Sun.COM #define ecb_keysched ecb_common.cc_keysched 957581SMark.Powers@Sun.COM #define ecb_keysched_len ecb_common.cc_keysched_len 967581SMark.Powers@Sun.COM #define ecb_iv ecb_common.cc_iv 977581SMark.Powers@Sun.COM #define ecb_remainder ecb_common.cc_remainder 987581SMark.Powers@Sun.COM #define ecb_remainder_len ecb_common.cc_remainder_len 997581SMark.Powers@Sun.COM #define ecb_lastp ecb_common.cc_lastp 1007581SMark.Powers@Sun.COM #define ecb_copy_to ecb_common.cc_copy_to 1017581SMark.Powers@Sun.COM #define ecb_flags ecb_common.cc_flags 1027581SMark.Powers@Sun.COM 1037581SMark.Powers@Sun.COM typedef struct cbc_ctx { 1047581SMark.Powers@Sun.COM struct common_ctx cbc_common; 1057581SMark.Powers@Sun.COM uint64_t cbc_lastblock[2]; 1067581SMark.Powers@Sun.COM } cbc_ctx_t; 1077581SMark.Powers@Sun.COM 1087581SMark.Powers@Sun.COM #define cbc_keysched cbc_common.cc_keysched 1097581SMark.Powers@Sun.COM #define cbc_keysched_len cbc_common.cc_keysched_len 1107581SMark.Powers@Sun.COM #define cbc_iv cbc_common.cc_iv 1117581SMark.Powers@Sun.COM #define cbc_remainder cbc_common.cc_remainder 1127581SMark.Powers@Sun.COM #define cbc_remainder_len cbc_common.cc_remainder_len 1137581SMark.Powers@Sun.COM #define cbc_lastp cbc_common.cc_lastp 1147581SMark.Powers@Sun.COM #define cbc_copy_to cbc_common.cc_copy_to 1157581SMark.Powers@Sun.COM #define cbc_flags cbc_common.cc_flags 1167581SMark.Powers@Sun.COM 1177581SMark.Powers@Sun.COM /* 1187581SMark.Powers@Sun.COM * ctr_lower_mask Bit-mask for lower 8 bytes of counter block. 1197581SMark.Powers@Sun.COM * ctr_upper_mask Bit-mask for upper 8 bytes of counter block. 1207581SMark.Powers@Sun.COM */ 1217188Smcpowers typedef struct ctr_ctx { 1227188Smcpowers struct common_ctx ctr_common; 1237581SMark.Powers@Sun.COM uint64_t ctr_lower_mask; 1247581SMark.Powers@Sun.COM uint64_t ctr_upper_mask; 1257188Smcpowers uint32_t ctr_tmp[4]; 1267188Smcpowers } ctr_ctx_t; 1277188Smcpowers 1287188Smcpowers /* 1297581SMark.Powers@Sun.COM * ctr_cb Counter block. 1307188Smcpowers */ 1317188Smcpowers #define ctr_keysched ctr_common.cc_keysched 1327188Smcpowers #define ctr_keysched_len ctr_common.cc_keysched_len 1337188Smcpowers #define ctr_cb ctr_common.cc_iv 1347188Smcpowers #define ctr_remainder ctr_common.cc_remainder 1357188Smcpowers #define ctr_remainder_len ctr_common.cc_remainder_len 1367188Smcpowers #define ctr_lastp ctr_common.cc_lastp 1377188Smcpowers #define ctr_copy_to ctr_common.cc_copy_to 1387188Smcpowers #define ctr_flags ctr_common.cc_flags 1397188Smcpowers 1407188Smcpowers /* 1417188Smcpowers * 1427188Smcpowers * ccm_mac_len: Stores length of the MAC in CCM mode. 1437188Smcpowers * ccm_mac_buf: Stores the intermediate value for MAC in CCM encrypt. 1447188Smcpowers * In CCM decrypt, stores the input MAC value. 1457188Smcpowers * ccm_data_len: Length of the plaintext for CCM mode encrypt, or 1467188Smcpowers * length of the ciphertext for CCM mode decrypt. 1477188Smcpowers * ccm_processed_data_len: 1487188Smcpowers * Length of processed plaintext in CCM mode encrypt, 1497188Smcpowers * or length of processed ciphertext for CCM mode decrypt. 1507188Smcpowers * ccm_processed_mac_len: 1517188Smcpowers * Length of MAC data accumulated in CCM mode decrypt. 1527188Smcpowers * 1537188Smcpowers * ccm_pt_buf: Only used in CCM mode decrypt. It stores the 1547188Smcpowers * decrypted plaintext to be returned when 1557188Smcpowers * MAC verification succeeds in decrypt_final. 1567188Smcpowers * Memory for this should be allocated in the AES module. 1577188Smcpowers * 1587188Smcpowers */ 1597188Smcpowers typedef struct ccm_ctx { 1607188Smcpowers struct common_ctx ccm_common; 1617188Smcpowers uint32_t ccm_tmp[4]; 1627188Smcpowers size_t ccm_mac_len; 1637188Smcpowers uint64_t ccm_mac_buf[2]; 1647188Smcpowers size_t ccm_data_len; 1657188Smcpowers size_t ccm_processed_data_len; 1667188Smcpowers size_t ccm_processed_mac_len; 1677188Smcpowers uint8_t *ccm_pt_buf; 1687188Smcpowers uint64_t ccm_mac_input_buf[2]; 1697581SMark.Powers@Sun.COM uint64_t ccm_counter_mask; 1707188Smcpowers } ccm_ctx_t; 1717188Smcpowers 1727188Smcpowers #define ccm_keysched ccm_common.cc_keysched 1737188Smcpowers #define ccm_keysched_len ccm_common.cc_keysched_len 1747188Smcpowers #define ccm_cb ccm_common.cc_iv 1757188Smcpowers #define ccm_remainder ccm_common.cc_remainder 1767188Smcpowers #define ccm_remainder_len ccm_common.cc_remainder_len 1777188Smcpowers #define ccm_lastp ccm_common.cc_lastp 1787188Smcpowers #define ccm_copy_to ccm_common.cc_copy_to 1797188Smcpowers #define ccm_flags ccm_common.cc_flags 1807188Smcpowers 1818005SMark.Powers@Sun.COM /* 1828005SMark.Powers@Sun.COM * gcm_tag_len: Length of authentication tag. 1838005SMark.Powers@Sun.COM * 1848005SMark.Powers@Sun.COM * gcm_ghash: Stores output from the GHASH function. 1858005SMark.Powers@Sun.COM * 1868005SMark.Powers@Sun.COM * gcm_processed_data_len: 1878005SMark.Powers@Sun.COM * Length of processed plaintext (encrypt) or 1888005SMark.Powers@Sun.COM * length of processed ciphertext (decrypt). 1898005SMark.Powers@Sun.COM * 1908005SMark.Powers@Sun.COM * gcm_pt_buf: Stores the decrypted plaintext returned by 1918005SMark.Powers@Sun.COM * decrypt_final when the computed authentication 1928005SMark.Powers@Sun.COM * tag matches the user supplied tag. 1938005SMark.Powers@Sun.COM * 1948005SMark.Powers@Sun.COM * gcm_pt_buf_len: Length of the plaintext buffer. 1958005SMark.Powers@Sun.COM * 1968005SMark.Powers@Sun.COM * gcm_H: Subkey. 1978005SMark.Powers@Sun.COM * 1988005SMark.Powers@Sun.COM * gcm_J0: Pre-counter block generated from the IV. 1998005SMark.Powers@Sun.COM * 2008005SMark.Powers@Sun.COM * gcm_len_a_len_c: 64-bit representations of the bit lengths of 2018005SMark.Powers@Sun.COM * AAD and ciphertext. 2028005SMark.Powers@Sun.COM * 2038005SMark.Powers@Sun.COM * gcm_kmflag: Current value of kmflag. Used only for allocating 2048005SMark.Powers@Sun.COM * the plaintext buffer during decryption. 2058005SMark.Powers@Sun.COM */ 2068005SMark.Powers@Sun.COM typedef struct gcm_ctx { 2078005SMark.Powers@Sun.COM struct common_ctx gcm_common; 2088005SMark.Powers@Sun.COM size_t gcm_tag_len; 2098005SMark.Powers@Sun.COM size_t gcm_processed_data_len; 2108005SMark.Powers@Sun.COM size_t gcm_pt_buf_len; 2118005SMark.Powers@Sun.COM uint32_t gcm_tmp[4]; 2128005SMark.Powers@Sun.COM uint64_t gcm_ghash[2]; 2138005SMark.Powers@Sun.COM uint64_t gcm_H[2]; 2148005SMark.Powers@Sun.COM uint64_t gcm_J0[2]; 2158005SMark.Powers@Sun.COM uint64_t gcm_len_a_len_c[2]; 2168005SMark.Powers@Sun.COM uint8_t *gcm_pt_buf; 2178005SMark.Powers@Sun.COM int gcm_kmflag; 2188005SMark.Powers@Sun.COM } gcm_ctx_t; 2198005SMark.Powers@Sun.COM 2208005SMark.Powers@Sun.COM #define gcm_keysched gcm_common.cc_keysched 2218005SMark.Powers@Sun.COM #define gcm_keysched_len gcm_common.cc_keysched_len 2228005SMark.Powers@Sun.COM #define gcm_cb gcm_common.cc_iv 2238005SMark.Powers@Sun.COM #define gcm_remainder gcm_common.cc_remainder 2248005SMark.Powers@Sun.COM #define gcm_remainder_len gcm_common.cc_remainder_len 2258005SMark.Powers@Sun.COM #define gcm_lastp gcm_common.cc_lastp 2268005SMark.Powers@Sun.COM #define gcm_copy_to gcm_common.cc_copy_to 2278005SMark.Powers@Sun.COM #define gcm_flags gcm_common.cc_flags 2288005SMark.Powers@Sun.COM 229*9339SMark.Powers@Sun.COM #define AES_GMAC_IV_LEN 12 230*9339SMark.Powers@Sun.COM #define AES_GMAC_TAG_BITS 128 231*9339SMark.Powers@Sun.COM 2327188Smcpowers typedef struct aes_ctx { 2337188Smcpowers union { 2347188Smcpowers ecb_ctx_t acu_ecb; 2357188Smcpowers cbc_ctx_t acu_cbc; 2367188Smcpowers ctr_ctx_t acu_ctr; 2377188Smcpowers #ifdef _KERNEL 2387188Smcpowers ccm_ctx_t acu_ccm; 2398005SMark.Powers@Sun.COM gcm_ctx_t acu_gcm; 2407188Smcpowers #endif 2417188Smcpowers } acu; 2427188Smcpowers } aes_ctx_t; 2437188Smcpowers 2447581SMark.Powers@Sun.COM #define ac_flags acu.acu_ecb.ecb_common.cc_flags 2457581SMark.Powers@Sun.COM #define ac_remainder_len acu.acu_ecb.ecb_common.cc_remainder_len 2467581SMark.Powers@Sun.COM #define ac_keysched acu.acu_ecb.ecb_common.cc_keysched 2477581SMark.Powers@Sun.COM #define ac_keysched_len acu.acu_ecb.ecb_common.cc_keysched_len 2487581SMark.Powers@Sun.COM #define ac_iv acu.acu_ecb.ecb_common.cc_iv 2497581SMark.Powers@Sun.COM #define ac_lastp acu.acu_ecb.ecb_common.cc_lastp 2507188Smcpowers #define ac_pt_buf acu.acu_ccm.ccm_pt_buf 2517188Smcpowers #define ac_mac_len acu.acu_ccm.ccm_mac_len 2527188Smcpowers #define ac_data_len acu.acu_ccm.ccm_data_len 2537188Smcpowers #define ac_processed_mac_len acu.acu_ccm.ccm_processed_mac_len 2547188Smcpowers #define ac_processed_data_len acu.acu_ccm.ccm_processed_data_len 2558195SMark.Powers@Sun.COM #define ac_tag_len acu.acu_gcm.gcm_tag_len 2567188Smcpowers 2577188Smcpowers typedef struct blowfish_ctx { 2587188Smcpowers union { 2597188Smcpowers ecb_ctx_t bcu_ecb; 2607188Smcpowers cbc_ctx_t bcu_cbc; 2617188Smcpowers } bcu; 2627188Smcpowers } blowfish_ctx_t; 2637188Smcpowers 2647581SMark.Powers@Sun.COM #define bc_flags bcu.bcu_ecb.ecb_common.cc_flags 2657581SMark.Powers@Sun.COM #define bc_remainder_len bcu.bcu_ecb.ecb_common.cc_remainder_len 2667581SMark.Powers@Sun.COM #define bc_keysched bcu.bcu_ecb.ecb_common.cc_keysched 2677581SMark.Powers@Sun.COM #define bc_keysched_len bcu.bcu_ecb.ecb_common.cc_keysched_len 2687581SMark.Powers@Sun.COM #define bc_iv bcu.bcu_ecb.ecb_common.cc_iv 2697581SMark.Powers@Sun.COM #define bc_lastp bcu.bcu_ecb.ecb_common.cc_lastp 2707188Smcpowers 2717188Smcpowers typedef struct des_ctx { 2727188Smcpowers union { 2737188Smcpowers ecb_ctx_t dcu_ecb; 2747188Smcpowers cbc_ctx_t dcu_cbc; 2757188Smcpowers } dcu; 2767188Smcpowers } des_ctx_t; 2777188Smcpowers 2787581SMark.Powers@Sun.COM #define dc_flags dcu.dcu_ecb.ecb_common.cc_flags 2797581SMark.Powers@Sun.COM #define dc_remainder_len dcu.dcu_ecb.ecb_common.cc_remainder_len 2807581SMark.Powers@Sun.COM #define dc_keysched dcu.dcu_ecb.ecb_common.cc_keysched 2817581SMark.Powers@Sun.COM #define dc_keysched_len dcu.dcu_ecb.ecb_common.cc_keysched_len 2827581SMark.Powers@Sun.COM #define dc_iv dcu.dcu_ecb.ecb_common.cc_iv 2837581SMark.Powers@Sun.COM #define dc_lastp dcu.dcu_ecb.ecb_common.cc_lastp 2847188Smcpowers 2857581SMark.Powers@Sun.COM extern int ecb_cipher_contiguous_blocks(ecb_ctx_t *, char *, size_t, 2867188Smcpowers crypto_data_t *, size_t, int (*cipher)(const void *, const uint8_t *, 2877188Smcpowers uint8_t *)); 2887188Smcpowers 2897188Smcpowers extern int cbc_encrypt_contiguous_blocks(cbc_ctx_t *, char *, size_t, 2907188Smcpowers crypto_data_t *, size_t, 2917188Smcpowers int (*encrypt)(const void *, const uint8_t *, uint8_t *), 2927188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 2937188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 2947188Smcpowers 2957188Smcpowers extern int cbc_decrypt_contiguous_blocks(cbc_ctx_t *, char *, size_t, 2967188Smcpowers crypto_data_t *, size_t, 2977188Smcpowers int (*decrypt)(const void *, const uint8_t *, uint8_t *), 2987188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 2997188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3007188Smcpowers 3017188Smcpowers extern int ctr_mode_contiguous_blocks(ctr_ctx_t *, char *, size_t, 3027188Smcpowers crypto_data_t *, size_t, 3037188Smcpowers int (*cipher)(const void *, const uint8_t *, uint8_t *), 3047188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3057188Smcpowers 3067188Smcpowers extern int ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *, char *, size_t, 3077188Smcpowers crypto_data_t *, size_t, 3087188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3097188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3107188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3117188Smcpowers 3127188Smcpowers extern int ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *, char *, size_t, 3137188Smcpowers crypto_data_t *, size_t, 3147188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3157188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3167188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3177188Smcpowers 3188005SMark.Powers@Sun.COM extern int gcm_mode_encrypt_contiguous_blocks(gcm_ctx_t *, char *, size_t, 3198005SMark.Powers@Sun.COM crypto_data_t *, size_t, 3208005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3218005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3228005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3238005SMark.Powers@Sun.COM 3248005SMark.Powers@Sun.COM extern int gcm_mode_decrypt_contiguous_blocks(gcm_ctx_t *, char *, size_t, 3258005SMark.Powers@Sun.COM crypto_data_t *, size_t, 3268005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3278005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3288005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3298005SMark.Powers@Sun.COM 3307188Smcpowers int ccm_encrypt_final(ccm_ctx_t *, crypto_data_t *, size_t, 3317188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3327188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3337188Smcpowers 3348005SMark.Powers@Sun.COM int gcm_encrypt_final(gcm_ctx_t *, crypto_data_t *, size_t, 3358005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3368005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3378005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3388005SMark.Powers@Sun.COM 3397188Smcpowers extern int ccm_decrypt_final(ccm_ctx_t *, crypto_data_t *, size_t, 3407188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3417188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3427188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3437188Smcpowers 3448005SMark.Powers@Sun.COM extern int gcm_decrypt_final(gcm_ctx_t *, crypto_data_t *, size_t, 3458005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3468005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3478005SMark.Powers@Sun.COM 3487188Smcpowers extern int ctr_mode_final(ctr_ctx_t *, crypto_data_t *, 3497188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *)); 3507188Smcpowers 3517188Smcpowers extern int cbc_init_ctx(cbc_ctx_t *, char *, size_t, size_t, 3527188Smcpowers void (*copy_block)(uint8_t *, uint64_t *)); 3537188Smcpowers 3547188Smcpowers extern int ctr_init_ctx(ctr_ctx_t *, ulong_t, uint8_t *, 3557188Smcpowers void (*copy_block)(uint8_t *, uint8_t *)); 3567188Smcpowers 3577188Smcpowers extern int ccm_init_ctx(ccm_ctx_t *, char *, int, boolean_t, size_t, 3587188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3597188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3607188Smcpowers 3618005SMark.Powers@Sun.COM extern int gcm_init_ctx(gcm_ctx_t *, char *, size_t, 3628005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3638005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3648005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3658005SMark.Powers@Sun.COM 366*9339SMark.Powers@Sun.COM extern int gmac_init_ctx(gcm_ctx_t *, char *, size_t, 367*9339SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 368*9339SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 369*9339SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 370*9339SMark.Powers@Sun.COM 3717188Smcpowers extern void calculate_ccm_mac(ccm_ctx_t *, uint8_t *, 3727188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *)); 3737188Smcpowers 3748559SMark.Powers@Sun.COM extern void gcm_mul(uint64_t *, uint64_t *, uint64_t *); 3758559SMark.Powers@Sun.COM 3767188Smcpowers extern void crypto_init_ptrs(crypto_data_t *, void **, offset_t *); 3777188Smcpowers extern void crypto_get_ptrs(crypto_data_t *, void **, offset_t *, 3787188Smcpowers uint8_t **, size_t *, uint8_t **, size_t); 3797188Smcpowers 3807188Smcpowers extern void *ecb_alloc_ctx(int); 3817188Smcpowers extern void *cbc_alloc_ctx(int); 3827188Smcpowers extern void *ctr_alloc_ctx(int); 3837188Smcpowers extern void *ccm_alloc_ctx(int); 3848005SMark.Powers@Sun.COM extern void *gcm_alloc_ctx(int); 385*9339SMark.Powers@Sun.COM extern void *gmac_alloc_ctx(int); 3867188Smcpowers extern void crypto_free_mode_ctx(void *); 3878005SMark.Powers@Sun.COM extern void gcm_set_kmflag(gcm_ctx_t *, int); 3887188Smcpowers 3897188Smcpowers #ifdef __cplusplus 3907188Smcpowers } 3917188Smcpowers #endif 3927188Smcpowers 3937188Smcpowers #endif /* _COMMON_CRYPTO_MODES_H */ 394