37 in particular, keyblock->contents is to be set to allocated storage.
38 It is the responsibility of the caller to release this storage
39 when the generated key no longer needed.
40
41 The routine may use "salt" to seed or alter the conversion
42 algorithm.
43
44 If the particular function called does not know how to make a
45 key of type "enctype", an error may be returned.
46
47 returns: errors
48 */
49
50 krb5_error_code
51 mit_des_string_to_key_int (krb5_context context,
52 krb5_keyblock *keyblock,
53 const krb5_data *data,
54 const krb5_data *salt)
55 {
56 krb5_error_code retval = KRB5_PROG_ETYPE_NOSUPP;
57 /* EXPORT DELETE START */
58 register char *str, *copystr;
59 register krb5_octet *key;
60 register unsigned temp;
61 register long i;
62 register int j;
63 register long length;
64 unsigned char *k_p;
65 int forward;
66 register char *p_char;
67 char k_char[64];
68
69 #ifndef min
70 #define min(A, B) ((A) < (B) ? (A): (B))
71 #endif
72
73 keyblock->magic = KV5M_KEYBLOCK;
74 keyblock->length = sizeof(mit_des_cblock);
75 key = keyblock->contents;
76
77 if (salt
163 (void) memset(copystr, 0, (size_t) length);
164 krb5_xfree(copystr);
165
166 /* now fix up key parity again */
167 mit_des_fixup_key_parity(key);
168 if (mit_des_is_weak_key(key))
169 ((krb5_octet *)key)[7] ^= 0xf0;
170
171 /*
172 * Because this routine actually modifies the original keyblock
173 * in place we cannot use the PKCS#11 key object handle created earlier.
174 * Destroy the existing object handle associated with the key,
175 * a correct handle will get created when the key is actually
176 * used for the first time.
177 */
178 if (keyblock->hKey != CK_INVALID_HANDLE) {
179 (void)C_DestroyObject(krb_ctx_hSession(context), keyblock->hKey);
180 keyblock->hKey = CK_INVALID_HANDLE;
181 }
182
183 /* EXPORT DELETE END */
184 return retval;
185 }
|
37 in particular, keyblock->contents is to be set to allocated storage.
38 It is the responsibility of the caller to release this storage
39 when the generated key no longer needed.
40
41 The routine may use "salt" to seed or alter the conversion
42 algorithm.
43
44 If the particular function called does not know how to make a
45 key of type "enctype", an error may be returned.
46
47 returns: errors
48 */
49
50 krb5_error_code
51 mit_des_string_to_key_int (krb5_context context,
52 krb5_keyblock *keyblock,
53 const krb5_data *data,
54 const krb5_data *salt)
55 {
56 krb5_error_code retval = KRB5_PROG_ETYPE_NOSUPP;
57 register char *str, *copystr;
58 register krb5_octet *key;
59 register unsigned temp;
60 register long i;
61 register int j;
62 register long length;
63 unsigned char *k_p;
64 int forward;
65 register char *p_char;
66 char k_char[64];
67
68 #ifndef min
69 #define min(A, B) ((A) < (B) ? (A): (B))
70 #endif
71
72 keyblock->magic = KV5M_KEYBLOCK;
73 keyblock->length = sizeof(mit_des_cblock);
74 key = keyblock->contents;
75
76 if (salt
162 (void) memset(copystr, 0, (size_t) length);
163 krb5_xfree(copystr);
164
165 /* now fix up key parity again */
166 mit_des_fixup_key_parity(key);
167 if (mit_des_is_weak_key(key))
168 ((krb5_octet *)key)[7] ^= 0xf0;
169
170 /*
171 * Because this routine actually modifies the original keyblock
172 * in place we cannot use the PKCS#11 key object handle created earlier.
173 * Destroy the existing object handle associated with the key,
174 * a correct handle will get created when the key is actually
175 * used for the first time.
176 */
177 if (keyblock->hKey != CK_INVALID_HANDLE) {
178 (void)C_DestroyObject(krb_ctx_hSession(context), keyblock->hKey);
179 keyblock->hKey = CK_INVALID_HANDLE;
180 }
181
182 return retval;
183 }
|