Print this page
3882 remove xmod & friends
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/gssapi/mechs/krb5/crypto/des/d3_cbc.c
+++ new/usr/src/uts/common/gssapi/mechs/krb5/crypto/des/d3_cbc.c
1 1 /*
2 2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 3 * Use is subject to license terms.
4 4 */
5 5
6 6 /*
7 7 * Copyright 1995 by Richard P. Basch. All Rights Reserved.
8 8 * Copyright 1995 by Lehman Brothers, Inc. All Rights Reserved.
9 9 *
10 10 * Export of this software from the United States of America may
11 11 * require a specific license from the United States Government.
12 12 * It is the responsibility of any person or organization contemplating
13 13 * export to obtain such a license before exporting.
14 14 *
15 15 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
16 16 * distribute this software and its documentation for any purpose and
17 17 * without fee is hereby granted, provided that the above copyright
18 18 * notice appear in all copies and that both that copyright notice and
19 19 * this permission notice appear in supporting documentation, and that
20 20 * the name of Richard P. Basch, Lehman Brothers and M.I.T. not be used
21 21 * in advertising or publicity pertaining to distribution of the software
22 22 * without specific, written prior permission. Richard P. Basch,
23 23 * Lehman Brothers and M.I.T. make no representations about the suitability
24 24 * of this software for any purpose. It is provided "as is" without
25 25 * express or implied warranty.
26 26 */
27 27
28 28 #include "des_int.h"
29 29
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
30 30 /*
31 31 * Triple-DES CBC encryption mode.
32 32 */
33 33 #ifndef _KERNEL
34 34 int
35 35 mit_des3_cbc_encrypt(krb5_context context, const mit_des_cblock *in, mit_des_cblock *out,
36 36 unsigned long length, krb5_keyblock *key,
37 37 const mit_des_cblock ivec, int encrypt)
38 38 {
39 39 int ret = KRB5_PROG_ETYPE_NOSUPP;
40 -/* EXPORT DELETE START */
41 40 KRB5_MECH_TO_PKCS algos;
42 41 CK_MECHANISM mechanism;
43 42 CK_RV rv;
44 43 /* For the Key Object */
45 44 ret = 0;
46 45
47 46 if ((rv = get_algo(key->enctype, &algos)) != CKR_OK) {
48 47 KRB5_LOG0(KRB5_ERR, "failure to get algo id in function "
49 48 "mit_des3_cbc_encrypt.");
50 49 ret = PKCS_ERR;
51 50 goto cleanup;
52 51 }
53 52
54 53 rv = init_key_uef(krb_ctx_hSession(context), key);
55 54 if (rv != CKR_OK) {
56 55 KRB5_LOG(KRB5_ERR, "init_key_uef failed in "
57 56 "mit_des3_cbc_encrypt: rv = 0x%0x", rv);
58 57 ret = PKCS_ERR;
59 58 goto cleanup;
60 59 }
61 60
62 61 mechanism.mechanism = algos.enc_algo;
63 62 mechanism.pParameter = (void*)ivec;
64 63 if (ivec != NULL)
65 64 mechanism.ulParameterLen = sizeof(mit_des_cblock);
66 65 else
67 66 mechanism.ulParameterLen = 0;
68 67
69 68 if (encrypt)
70 69 rv = C_EncryptInit(krb_ctx_hSession(context), &mechanism, key->hKey);
71 70 else
72 71 rv = C_DecryptInit(krb_ctx_hSession(context), &mechanism, key->hKey);
73 72
74 73 if (rv != CKR_OK) {
75 74 KRB5_LOG(KRB5_ERR, "C_EncryptInit/C_DecryptInit failed in "
76 75 "mit_des3_cbc_encrypt: rv = 0x%x", rv);
77 76 ret = PKCS_ERR;
78 77 goto cleanup;
79 78 }
80 79
81 80 if (encrypt)
82 81 rv = C_Encrypt(krb_ctx_hSession(context), (CK_BYTE_PTR)in,
83 82 (CK_ULONG)length, (CK_BYTE_PTR)out,
84 83 (CK_ULONG_PTR)&length);
85 84 else
86 85 rv = C_Decrypt(krb_ctx_hSession(context), (CK_BYTE_PTR)in,
87 86 (CK_ULONG)length, (CK_BYTE_PTR)out,
88 87 (CK_ULONG_PTR)&length);
89 88
90 89 if (rv != CKR_OK) {
91 90 KRB5_LOG(KRB5_ERR,
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
92 91 "C_Encrypt/C_Decrypt failed in mit_des3_cbc_encrypt: "
93 92 "rv = 0x%x", rv);
94 93 ret = PKCS_ERR;
95 94 }
96 95 cleanup:
97 96
98 97 final_cleanup:
99 98 if (ret)
100 99 (void) memset(out, 0, length);
101 100
102 -/* EXPORT DELETE END */
103 101 KRB5_LOG(KRB5_INFO, "mit_des3_cbc_encrypt() end ret=%d\n", ret);
104 102 return(ret);
105 103 }
106 104
107 105 #else
108 106 #include <sys/crypto/api.h>
109 107
110 108 /* ARGSUSED */
111 109 int
112 110 mit_des3_cbc_encrypt(krb5_context context,
113 111 const mit_des_cblock *in,
114 112 mit_des_cblock *out,
115 113 unsigned long length, krb5_keyblock *key,
116 114 const mit_des_cblock ivec, int encrypt)
117 115 {
118 116 int ret = KRB5_PROG_ETYPE_NOSUPP;
119 -/* EXPORT DELETE START */
120 117 krb5_data ivdata;
121 118
122 119 KRB5_LOG(KRB5_INFO, "mit_des3_cbc_encrypt() start encrypt=%d", encrypt);
123 120
124 121 ivdata.data = (char *)ivec;
125 122 ivdata.length = sizeof(mit_des_cblock);
126 123
127 124 ret = k5_ef_crypto((const char *)in, (char *)out,
128 125 length, key, &ivdata, encrypt);
129 126
130 -/* EXPORT DELETE END */
131 127 KRB5_LOG(KRB5_INFO, "mit_des3_cbc_encrypt() end retval=%d", ret);
132 128 return(ret);
133 129 }
134 130 #endif /* !_KERNEL */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX