crypto: Fixes for recent Heimdal changes
[openafs.git] / src / crypto / rfc3961 / copy.c
1 /* A couple of copying functions which are required by the Heimdal crypto code,
2  * but where pulling in the whole Heimdal source file containing them leads
3  * to unecessary complexity */
4
5 #include <krb5_locl.h>
6
7 int
8 der_copy_octet_string (const krb5_data *from, krb5_data *to)
9 {
10     to->length = from->length;
11     to->data   = malloc(to->length);
12     if(to->length != 0 && to->data == NULL)
13         return ENOMEM;
14     memcpy(to->data, from->data, to->length);
15     return 0;
16 }
17
18 int
19 copy_EncryptionKey(const krb5_keyblock *from, krb5_keyblock *to)
20 {
21     memset(to, 0, sizeof(*to));
22     to->keytype = from->keytype;
23     return der_copy_octet_string(&from->keyvalue, &to->keyvalue);
24 }
25
26 void
27 free_Checksum(Checksum *data)
28 {
29     krb5_data_free(&data->checksum);
30 }