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 /* 22*8559SMark.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 487188Smcpowers 497188Smcpowers /* 507188Smcpowers * cc_keysched: Pointer to key schedule. 517188Smcpowers * 527188Smcpowers * cc_keysched_len: Length of the key schedule. 537188Smcpowers * 547188Smcpowers * cc_remainder: This is for residual data, i.e. data that can't 557188Smcpowers * be processed because there are too few bytes. 567188Smcpowers * Must wait until more data arrives. 577188Smcpowers * 587188Smcpowers * cc_remainder_len: Number of bytes in cc_remainder. 597188Smcpowers * 607188Smcpowers * cc_iv: Scratch buffer that sometimes contains the IV. 617188Smcpowers * 627188Smcpowers * cc_lastp: Pointer to previous block of ciphertext. 637188Smcpowers * 647188Smcpowers * cc_copy_to: Pointer to where encrypted residual data needs 657188Smcpowers * to be copied. 667188Smcpowers * 677188Smcpowers * cc_flags: PROVIDER_OWNS_KEY_SCHEDULE 687188Smcpowers * When a context is freed, it is necessary 697188Smcpowers * to know whether the key schedule was allocated 707188Smcpowers * by the caller, or internally, e.g. an init routine. 717188Smcpowers * If allocated by the latter, then it needs to be freed. 727188Smcpowers * 737188Smcpowers * ECB_MODE, CBC_MODE, CTR_MODE, or CCM_MODE 747188Smcpowers */ 757188Smcpowers struct common_ctx { 767188Smcpowers void *cc_keysched; 777188Smcpowers size_t cc_keysched_len; 787188Smcpowers uint64_t cc_iv[2]; 797188Smcpowers uint64_t cc_remainder[2]; 807188Smcpowers size_t cc_remainder_len; 817188Smcpowers uint8_t *cc_lastp; 827188Smcpowers uint8_t *cc_copy_to; 837188Smcpowers uint32_t cc_flags; 847188Smcpowers }; 857188Smcpowers 867188Smcpowers typedef struct common_ctx common_ctx_t; 877188Smcpowers 887581SMark.Powers@Sun.COM typedef struct ecb_ctx { 897581SMark.Powers@Sun.COM struct common_ctx ecb_common; 907581SMark.Powers@Sun.COM uint64_t ecb_lastblock[2]; 917581SMark.Powers@Sun.COM } ecb_ctx_t; 927581SMark.Powers@Sun.COM 937581SMark.Powers@Sun.COM #define ecb_keysched ecb_common.cc_keysched 947581SMark.Powers@Sun.COM #define ecb_keysched_len ecb_common.cc_keysched_len 957581SMark.Powers@Sun.COM #define ecb_iv ecb_common.cc_iv 967581SMark.Powers@Sun.COM #define ecb_remainder ecb_common.cc_remainder 977581SMark.Powers@Sun.COM #define ecb_remainder_len ecb_common.cc_remainder_len 987581SMark.Powers@Sun.COM #define ecb_lastp ecb_common.cc_lastp 997581SMark.Powers@Sun.COM #define ecb_copy_to ecb_common.cc_copy_to 1007581SMark.Powers@Sun.COM #define ecb_flags ecb_common.cc_flags 1017581SMark.Powers@Sun.COM 1027581SMark.Powers@Sun.COM typedef struct cbc_ctx { 1037581SMark.Powers@Sun.COM struct common_ctx cbc_common; 1047581SMark.Powers@Sun.COM uint64_t cbc_lastblock[2]; 1057581SMark.Powers@Sun.COM } cbc_ctx_t; 1067581SMark.Powers@Sun.COM 1077581SMark.Powers@Sun.COM #define cbc_keysched cbc_common.cc_keysched 1087581SMark.Powers@Sun.COM #define cbc_keysched_len cbc_common.cc_keysched_len 1097581SMark.Powers@Sun.COM #define cbc_iv cbc_common.cc_iv 1107581SMark.Powers@Sun.COM #define cbc_remainder cbc_common.cc_remainder 1117581SMark.Powers@Sun.COM #define cbc_remainder_len cbc_common.cc_remainder_len 1127581SMark.Powers@Sun.COM #define cbc_lastp cbc_common.cc_lastp 1137581SMark.Powers@Sun.COM #define cbc_copy_to cbc_common.cc_copy_to 1147581SMark.Powers@Sun.COM #define cbc_flags cbc_common.cc_flags 1157581SMark.Powers@Sun.COM 1167581SMark.Powers@Sun.COM /* 1177581SMark.Powers@Sun.COM * ctr_lower_mask Bit-mask for lower 8 bytes of counter block. 1187581SMark.Powers@Sun.COM * ctr_upper_mask Bit-mask for upper 8 bytes of counter block. 1197581SMark.Powers@Sun.COM */ 1207188Smcpowers typedef struct ctr_ctx { 1217188Smcpowers struct common_ctx ctr_common; 1227581SMark.Powers@Sun.COM uint64_t ctr_lower_mask; 1237581SMark.Powers@Sun.COM uint64_t ctr_upper_mask; 1247188Smcpowers uint32_t ctr_tmp[4]; 1257188Smcpowers } ctr_ctx_t; 1267188Smcpowers 1277188Smcpowers /* 1287581SMark.Powers@Sun.COM * ctr_cb Counter block. 1297188Smcpowers */ 1307188Smcpowers #define ctr_keysched ctr_common.cc_keysched 1317188Smcpowers #define ctr_keysched_len ctr_common.cc_keysched_len 1327188Smcpowers #define ctr_cb ctr_common.cc_iv 1337188Smcpowers #define ctr_remainder ctr_common.cc_remainder 1347188Smcpowers #define ctr_remainder_len ctr_common.cc_remainder_len 1357188Smcpowers #define ctr_lastp ctr_common.cc_lastp 1367188Smcpowers #define ctr_copy_to ctr_common.cc_copy_to 1377188Smcpowers #define ctr_flags ctr_common.cc_flags 1387188Smcpowers 1397188Smcpowers /* 1407188Smcpowers * 1417188Smcpowers * ccm_mac_len: Stores length of the MAC in CCM mode. 1427188Smcpowers * ccm_mac_buf: Stores the intermediate value for MAC in CCM encrypt. 1437188Smcpowers * In CCM decrypt, stores the input MAC value. 1447188Smcpowers * ccm_data_len: Length of the plaintext for CCM mode encrypt, or 1457188Smcpowers * length of the ciphertext for CCM mode decrypt. 1467188Smcpowers * ccm_processed_data_len: 1477188Smcpowers * Length of processed plaintext in CCM mode encrypt, 1487188Smcpowers * or length of processed ciphertext for CCM mode decrypt. 1497188Smcpowers * ccm_processed_mac_len: 1507188Smcpowers * Length of MAC data accumulated in CCM mode decrypt. 1517188Smcpowers * 1527188Smcpowers * ccm_pt_buf: Only used in CCM mode decrypt. It stores the 1537188Smcpowers * decrypted plaintext to be returned when 1547188Smcpowers * MAC verification succeeds in decrypt_final. 1557188Smcpowers * Memory for this should be allocated in the AES module. 1567188Smcpowers * 1577188Smcpowers */ 1587188Smcpowers typedef struct ccm_ctx { 1597188Smcpowers struct common_ctx ccm_common; 1607188Smcpowers uint32_t ccm_tmp[4]; 1617188Smcpowers size_t ccm_mac_len; 1627188Smcpowers uint64_t ccm_mac_buf[2]; 1637188Smcpowers size_t ccm_data_len; 1647188Smcpowers size_t ccm_processed_data_len; 1657188Smcpowers size_t ccm_processed_mac_len; 1667188Smcpowers uint8_t *ccm_pt_buf; 1677188Smcpowers uint64_t ccm_mac_input_buf[2]; 1687581SMark.Powers@Sun.COM uint64_t ccm_counter_mask; 1697188Smcpowers } ccm_ctx_t; 1707188Smcpowers 1717188Smcpowers #define ccm_keysched ccm_common.cc_keysched 1727188Smcpowers #define ccm_keysched_len ccm_common.cc_keysched_len 1737188Smcpowers #define ccm_cb ccm_common.cc_iv 1747188Smcpowers #define ccm_remainder ccm_common.cc_remainder 1757188Smcpowers #define ccm_remainder_len ccm_common.cc_remainder_len 1767188Smcpowers #define ccm_lastp ccm_common.cc_lastp 1777188Smcpowers #define ccm_copy_to ccm_common.cc_copy_to 1787188Smcpowers #define ccm_flags ccm_common.cc_flags 1797188Smcpowers 1808005SMark.Powers@Sun.COM /* 1818005SMark.Powers@Sun.COM * gcm_tag_len: Length of authentication tag. 1828005SMark.Powers@Sun.COM * 1838005SMark.Powers@Sun.COM * gcm_ghash: Stores output from the GHASH function. 1848005SMark.Powers@Sun.COM * 1858005SMark.Powers@Sun.COM * gcm_processed_data_len: 1868005SMark.Powers@Sun.COM * Length of processed plaintext (encrypt) or 1878005SMark.Powers@Sun.COM * length of processed ciphertext (decrypt). 1888005SMark.Powers@Sun.COM * 1898005SMark.Powers@Sun.COM * gcm_pt_buf: Stores the decrypted plaintext returned by 1908005SMark.Powers@Sun.COM * decrypt_final when the computed authentication 1918005SMark.Powers@Sun.COM * tag matches the user supplied tag. 1928005SMark.Powers@Sun.COM * 1938005SMark.Powers@Sun.COM * gcm_pt_buf_len: Length of the plaintext buffer. 1948005SMark.Powers@Sun.COM * 1958005SMark.Powers@Sun.COM * gcm_H: Subkey. 1968005SMark.Powers@Sun.COM * 1978005SMark.Powers@Sun.COM * gcm_J0: Pre-counter block generated from the IV. 1988005SMark.Powers@Sun.COM * 1998005SMark.Powers@Sun.COM * gcm_len_a_len_c: 64-bit representations of the bit lengths of 2008005SMark.Powers@Sun.COM * AAD and ciphertext. 2018005SMark.Powers@Sun.COM * 2028005SMark.Powers@Sun.COM * gcm_kmflag: Current value of kmflag. Used only for allocating 2038005SMark.Powers@Sun.COM * the plaintext buffer during decryption. 2048005SMark.Powers@Sun.COM */ 2058005SMark.Powers@Sun.COM typedef struct gcm_ctx { 2068005SMark.Powers@Sun.COM struct common_ctx gcm_common; 2078005SMark.Powers@Sun.COM size_t gcm_tag_len; 2088005SMark.Powers@Sun.COM size_t gcm_processed_data_len; 2098005SMark.Powers@Sun.COM size_t gcm_pt_buf_len; 2108005SMark.Powers@Sun.COM uint32_t gcm_tmp[4]; 2118005SMark.Powers@Sun.COM uint64_t gcm_ghash[2]; 2128005SMark.Powers@Sun.COM uint64_t gcm_H[2]; 2138005SMark.Powers@Sun.COM uint64_t gcm_J0[2]; 2148005SMark.Powers@Sun.COM uint64_t gcm_len_a_len_c[2]; 2158005SMark.Powers@Sun.COM uint8_t *gcm_pt_buf; 2168005SMark.Powers@Sun.COM int gcm_kmflag; 2178005SMark.Powers@Sun.COM } gcm_ctx_t; 2188005SMark.Powers@Sun.COM 2198005SMark.Powers@Sun.COM #define gcm_keysched gcm_common.cc_keysched 2208005SMark.Powers@Sun.COM #define gcm_keysched_len gcm_common.cc_keysched_len 2218005SMark.Powers@Sun.COM #define gcm_cb gcm_common.cc_iv 2228005SMark.Powers@Sun.COM #define gcm_remainder gcm_common.cc_remainder 2238005SMark.Powers@Sun.COM #define gcm_remainder_len gcm_common.cc_remainder_len 2248005SMark.Powers@Sun.COM #define gcm_lastp gcm_common.cc_lastp 2258005SMark.Powers@Sun.COM #define gcm_copy_to gcm_common.cc_copy_to 2268005SMark.Powers@Sun.COM #define gcm_flags gcm_common.cc_flags 2278005SMark.Powers@Sun.COM 2287188Smcpowers typedef struct aes_ctx { 2297188Smcpowers union { 2307188Smcpowers ecb_ctx_t acu_ecb; 2317188Smcpowers cbc_ctx_t acu_cbc; 2327188Smcpowers ctr_ctx_t acu_ctr; 2337188Smcpowers #ifdef _KERNEL 2347188Smcpowers ccm_ctx_t acu_ccm; 2358005SMark.Powers@Sun.COM gcm_ctx_t acu_gcm; 2367188Smcpowers #endif 2377188Smcpowers } acu; 2387188Smcpowers } aes_ctx_t; 2397188Smcpowers 2407581SMark.Powers@Sun.COM #define ac_flags acu.acu_ecb.ecb_common.cc_flags 2417581SMark.Powers@Sun.COM #define ac_remainder_len acu.acu_ecb.ecb_common.cc_remainder_len 2427581SMark.Powers@Sun.COM #define ac_keysched acu.acu_ecb.ecb_common.cc_keysched 2437581SMark.Powers@Sun.COM #define ac_keysched_len acu.acu_ecb.ecb_common.cc_keysched_len 2447581SMark.Powers@Sun.COM #define ac_iv acu.acu_ecb.ecb_common.cc_iv 2457581SMark.Powers@Sun.COM #define ac_lastp acu.acu_ecb.ecb_common.cc_lastp 2467188Smcpowers #define ac_pt_buf acu.acu_ccm.ccm_pt_buf 2477188Smcpowers #define ac_mac_len acu.acu_ccm.ccm_mac_len 2487188Smcpowers #define ac_data_len acu.acu_ccm.ccm_data_len 2497188Smcpowers #define ac_processed_mac_len acu.acu_ccm.ccm_processed_mac_len 2507188Smcpowers #define ac_processed_data_len acu.acu_ccm.ccm_processed_data_len 2518195SMark.Powers@Sun.COM #define ac_tag_len acu.acu_gcm.gcm_tag_len 2527188Smcpowers 2537188Smcpowers typedef struct blowfish_ctx { 2547188Smcpowers union { 2557188Smcpowers ecb_ctx_t bcu_ecb; 2567188Smcpowers cbc_ctx_t bcu_cbc; 2577188Smcpowers } bcu; 2587188Smcpowers } blowfish_ctx_t; 2597188Smcpowers 2607581SMark.Powers@Sun.COM #define bc_flags bcu.bcu_ecb.ecb_common.cc_flags 2617581SMark.Powers@Sun.COM #define bc_remainder_len bcu.bcu_ecb.ecb_common.cc_remainder_len 2627581SMark.Powers@Sun.COM #define bc_keysched bcu.bcu_ecb.ecb_common.cc_keysched 2637581SMark.Powers@Sun.COM #define bc_keysched_len bcu.bcu_ecb.ecb_common.cc_keysched_len 2647581SMark.Powers@Sun.COM #define bc_iv bcu.bcu_ecb.ecb_common.cc_iv 2657581SMark.Powers@Sun.COM #define bc_lastp bcu.bcu_ecb.ecb_common.cc_lastp 2667188Smcpowers 2677188Smcpowers typedef struct des_ctx { 2687188Smcpowers union { 2697188Smcpowers ecb_ctx_t dcu_ecb; 2707188Smcpowers cbc_ctx_t dcu_cbc; 2717188Smcpowers } dcu; 2727188Smcpowers } des_ctx_t; 2737188Smcpowers 2747581SMark.Powers@Sun.COM #define dc_flags dcu.dcu_ecb.ecb_common.cc_flags 2757581SMark.Powers@Sun.COM #define dc_remainder_len dcu.dcu_ecb.ecb_common.cc_remainder_len 2767581SMark.Powers@Sun.COM #define dc_keysched dcu.dcu_ecb.ecb_common.cc_keysched 2777581SMark.Powers@Sun.COM #define dc_keysched_len dcu.dcu_ecb.ecb_common.cc_keysched_len 2787581SMark.Powers@Sun.COM #define dc_iv dcu.dcu_ecb.ecb_common.cc_iv 2797581SMark.Powers@Sun.COM #define dc_lastp dcu.dcu_ecb.ecb_common.cc_lastp 2807188Smcpowers 2817581SMark.Powers@Sun.COM extern int ecb_cipher_contiguous_blocks(ecb_ctx_t *, char *, size_t, 2827188Smcpowers crypto_data_t *, size_t, int (*cipher)(const void *, const uint8_t *, 2837188Smcpowers uint8_t *)); 2847188Smcpowers 2857188Smcpowers extern int cbc_encrypt_contiguous_blocks(cbc_ctx_t *, char *, size_t, 2867188Smcpowers crypto_data_t *, size_t, 2877188Smcpowers int (*encrypt)(const void *, const uint8_t *, uint8_t *), 2887188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 2897188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 2907188Smcpowers 2917188Smcpowers extern int cbc_decrypt_contiguous_blocks(cbc_ctx_t *, char *, size_t, 2927188Smcpowers crypto_data_t *, size_t, 2937188Smcpowers int (*decrypt)(const void *, const uint8_t *, uint8_t *), 2947188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 2957188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 2967188Smcpowers 2977188Smcpowers extern int ctr_mode_contiguous_blocks(ctr_ctx_t *, char *, size_t, 2987188Smcpowers crypto_data_t *, size_t, 2997188Smcpowers int (*cipher)(const void *, const uint8_t *, uint8_t *), 3007188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3017188Smcpowers 3027188Smcpowers extern int ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *, char *, size_t, 3037188Smcpowers crypto_data_t *, size_t, 3047188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3057188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3067188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3077188Smcpowers 3087188Smcpowers extern int ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *, char *, size_t, 3097188Smcpowers crypto_data_t *, size_t, 3107188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3117188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3127188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3137188Smcpowers 3148005SMark.Powers@Sun.COM extern int gcm_mode_encrypt_contiguous_blocks(gcm_ctx_t *, char *, size_t, 3158005SMark.Powers@Sun.COM crypto_data_t *, size_t, 3168005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3178005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3188005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3198005SMark.Powers@Sun.COM 3208005SMark.Powers@Sun.COM extern int gcm_mode_decrypt_contiguous_blocks(gcm_ctx_t *, char *, size_t, 3218005SMark.Powers@Sun.COM crypto_data_t *, size_t, 3228005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3238005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3248005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3258005SMark.Powers@Sun.COM 3267188Smcpowers int ccm_encrypt_final(ccm_ctx_t *, crypto_data_t *, size_t, 3277188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3287188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3297188Smcpowers 3308005SMark.Powers@Sun.COM int gcm_encrypt_final(gcm_ctx_t *, crypto_data_t *, size_t, 3318005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3328005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3338005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3348005SMark.Powers@Sun.COM 3357188Smcpowers extern int ccm_decrypt_final(ccm_ctx_t *, crypto_data_t *, size_t, 3367188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3377188Smcpowers void (*copy_block)(uint8_t *, uint8_t *), 3387188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3397188Smcpowers 3408005SMark.Powers@Sun.COM extern int gcm_decrypt_final(gcm_ctx_t *, crypto_data_t *, size_t, 3418005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3428005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3438005SMark.Powers@Sun.COM 3447188Smcpowers extern int ctr_mode_final(ctr_ctx_t *, crypto_data_t *, 3457188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *)); 3467188Smcpowers 3477188Smcpowers extern int cbc_init_ctx(cbc_ctx_t *, char *, size_t, size_t, 3487188Smcpowers void (*copy_block)(uint8_t *, uint64_t *)); 3497188Smcpowers 3507188Smcpowers extern int ctr_init_ctx(ctr_ctx_t *, ulong_t, uint8_t *, 3517188Smcpowers void (*copy_block)(uint8_t *, uint8_t *)); 3527188Smcpowers 3537188Smcpowers extern int ccm_init_ctx(ccm_ctx_t *, char *, int, boolean_t, size_t, 3547188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3557188Smcpowers void (*xor_block)(uint8_t *, uint8_t *)); 3567188Smcpowers 3578005SMark.Powers@Sun.COM extern int gcm_init_ctx(gcm_ctx_t *, char *, size_t, 3588005SMark.Powers@Sun.COM int (*encrypt_block)(const void *, const uint8_t *, uint8_t *), 3598005SMark.Powers@Sun.COM void (*copy_block)(uint8_t *, uint8_t *), 3608005SMark.Powers@Sun.COM void (*xor_block)(uint8_t *, uint8_t *)); 3618005SMark.Powers@Sun.COM 3627188Smcpowers extern void calculate_ccm_mac(ccm_ctx_t *, uint8_t *, 3637188Smcpowers int (*encrypt_block)(const void *, const uint8_t *, uint8_t *)); 3647188Smcpowers 365*8559SMark.Powers@Sun.COM extern void gcm_mul(uint64_t *, uint64_t *, uint64_t *); 366*8559SMark.Powers@Sun.COM 3677188Smcpowers extern void crypto_init_ptrs(crypto_data_t *, void **, offset_t *); 3687188Smcpowers extern void crypto_get_ptrs(crypto_data_t *, void **, offset_t *, 3697188Smcpowers uint8_t **, size_t *, uint8_t **, size_t); 3707188Smcpowers 3717188Smcpowers extern void *ecb_alloc_ctx(int); 3727188Smcpowers extern void *cbc_alloc_ctx(int); 3737188Smcpowers extern void *ctr_alloc_ctx(int); 3747188Smcpowers extern void *ccm_alloc_ctx(int); 3758005SMark.Powers@Sun.COM extern void *gcm_alloc_ctx(int); 3767188Smcpowers extern void crypto_free_mode_ctx(void *); 3778005SMark.Powers@Sun.COM extern void gcm_set_kmflag(gcm_ctx_t *, int); 3787188Smcpowers 3797188Smcpowers #ifdef __cplusplus 3807188Smcpowers } 3817188Smcpowers #endif 3827188Smcpowers 3837188Smcpowers #endif /* _COMMON_CRYPTO_MODES_H */ 384