1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2017 Jason King
14 * Copyright (c) 2017, Joyent, Inc.
15 */
16
17 #ifndef _PRF_H
18 #define _PRF_H
19
20 #include <sys/types.h>
21 #include <security/cryptoki.h>
22 #include "buf.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #ifndef _PRFP_T
29 #define _PRFP_T
30 struct prfp_s {
31 CK_OBJECT_HANDLE key;
32 int i2alg;
33 buf_t tbuf[2];
34 buf_t seed;
35 buf_t prf_arg[3];
36 size_t pos;
37 uint8_t n;
38 };
39 typedef struct prfp_s prfp_t;
40 #endif /* _PRFP_T */
41
42 /* These are internal to in.ikev2d, so don't bother with ugly !C99 compat */
43 CK_RV prf_key(CK_MECHANISM_TYPE, buf_t *restrict, size_t,
44 CK_OBJECT_HANDLE_PTR restrict);
45
46 CK_RV prf(int, CK_OBJECT_HANDLE, buf_t *restrict, size_t, buf_t *restrict);
47
48 CK_RV prfplus_init(prfp_t *restrict, int, CK_OBJECT_HANDLE,
49 const buf_t *restrict);
50 void prfplus_fini(prfp_t *);
51 CK_RV prfplus(prfp_t *restrict, buf_t *restrict);
52
53 size_t ikev2_prf_keylen(int);
54
55 #ifdef __cplusplus
56 }
57 #endif
58
59 #endif /* _PRF_H */