struct addrlist *, enum locate_service_type svc,
int sockettype, int family);
+/* Internal structure of an opaque key identifier */
+struct krb5_key_st {
+ krb5_keyblock keyblock;
+};
+
/* new encryption provider api */
struct krb5_enc_provider {
(krb5_context context, krb5_keyblock *key1, krb5_keyblock *key2,
krb5_keyblock *outkey);
+
void krb5int_c_free_keyblock
(krb5_context, krb5_keyblock *key);
void krb5int_c_free_keyblock_contents
(krb5_context, krb5_keyblock *);
-krb5_error_code krb5int_c_init_keyblock
+krb5_error_code krb5int_c_init_keyblock
(krb5_context, krb5_enctype enctype,
size_t length, krb5_keyblock **out);
+krb5_error_code krb5int_c_copy_keyblock
+(krb5_context context, const krb5_keyblock *from, krb5_keyblock **to);
+krb5_error_code krb5int_c_copy_keyblock_contents
+(krb5_context context, const krb5_keyblock *from, krb5_keyblock *to);
/*
* Internal - for cleanup.
* begin "encryption.h"
*/
+/* Exposed contents of a key. */
typedef struct _krb5_keyblock {
krb5_magic magic;
krb5_enctype enctype;
krb5_octet *contents;
} krb5_keyblock;
+/*
+ * Opaque identifier for a key. Use with the krb5_k APIs for better
+ * performance for repeated operations with the same key usage.
+ */
+struct krb5_key_st;
+typedef struct krb5_key_st *krb5_key;
+
#ifdef KRB5_OLD_CRYPTO
typedef struct _krb5_encrypt_block {
krb5_magic magic;
(krb5_context context, krb5_enctype enctype,
size_t data_length, unsigned int *size);
+/*
+ * krb5_k_* functions use opaque key identifiers and should perform
+ * better for repeated operations with the same key usage.
+ */
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_create_key(krb5_context context, krb5_keyblock *key_data,
+ krb5_key *out);
+
+void KRB5_CALLCONV krb5_k_free_key(krb5_context context, krb5_key key);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_key_keyblock(krb5_context context, krb5_key key,
+ krb5_keyblock **key_data);
+
+krb5_enctype KRB5_CALLCONV
+krb5_k_key_enctype(krb5_context context, krb5_key key);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_encrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
+ const krb5_data *cipher_state, const krb5_data *input,
+ krb5_enc_data *output);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_encrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
+ const krb5_data *cipher_state, krb5_crypto_iov *data,
+ size_t num_data);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_decrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
+ const krb5_data *cipher_state, const krb5_enc_data *input,
+ krb5_data *output);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_decrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
+ const krb5_data *cipher_state, krb5_crypto_iov *data,
+ size_t num_data);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype,
+ krb5_key key, krb5_keyusage usage, const krb5_data *input,
+ krb5_checksum *cksum);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_make_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
+ krb5_key key, krb5_keyusage usage,
+ krb5_crypto_iov *data, size_t num_data);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_verify_checksum(krb5_context context, krb5_key key, krb5_keyusage usage,
+ const krb5_data *data, const krb5_checksum *cksum,
+ krb5_boolean *valid);
+
+krb5_error_code KRB5_CALLCONV
+krb5_k_verify_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
+ krb5_key key, krb5_keyusage usage,
+ const krb5_crypto_iov *data, size_t num_data,
+ krb5_boolean *valid);
+
#ifdef KRB5_OLD_CRYPTO
/*
* old cryptosystem routine prototypes. These are now layered
return 0;
}
-
void
krb5int_c_free_keyblock(krb5_context context, register krb5_keyblock *val)
{
key->contents = 0;
}
}
+
+krb5_error_code
+krb5int_c_copy_keyblock(krb5_context context, const krb5_keyblock *from,
+ krb5_keyblock **to)
+{
+ krb5_keyblock *new_key;
+ krb5_error_code code;
+
+ *to = NULL;
+ new_key = malloc(sizeof(*new_key));
+ if (!new_key)
+ return ENOMEM;
+ code = krb5int_c_copy_keyblock_contents(context, from, new_key);
+ if (code) {
+ free(new_key);
+ return code;
+ }
+ *to = new_key;
+ return 0;
+}
+
+krb5_error_code
+krb5int_c_copy_keyblock_contents(krb5_context context,
+ const krb5_keyblock *from, krb5_keyblock *to)
+{
+ *to = *from;
+ if (to->length) {
+ to->contents = malloc(to->length);
+ if (!to->contents)
+ return ENOMEM;
+ memcpy(to->contents, from->contents, to->length);
+ } else
+ to->contents = 0;
+ return 0;
+}