xref: /freebsd/crypto/krb5/src/include/k5-int-pkinit.h (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert  * COPYRIGHT (C) 2006
4*7f2fe78bSCy Schubert  * THE REGENTS OF THE UNIVERSITY OF MICHIGAN
5*7f2fe78bSCy Schubert  * ALL RIGHTS RESERVED
6*7f2fe78bSCy Schubert  *
7*7f2fe78bSCy Schubert  * Permission is granted to use, copy, create derivative works
8*7f2fe78bSCy Schubert  * and redistribute this software and such derivative works
9*7f2fe78bSCy Schubert  * for any purpose, so long as the name of The University of
10*7f2fe78bSCy Schubert  * Michigan is not used in any advertising or publicity
11*7f2fe78bSCy Schubert  * pertaining to the use of distribution of this software
12*7f2fe78bSCy Schubert  * without specific, written prior authorization.  If the
13*7f2fe78bSCy Schubert  * above copyright notice or any other identification of the
14*7f2fe78bSCy Schubert  * University of Michigan is included in any copy of any
15*7f2fe78bSCy Schubert  * portion of this software, then the disclaimer below must
16*7f2fe78bSCy Schubert  * also be included.
17*7f2fe78bSCy Schubert  *
18*7f2fe78bSCy Schubert  * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION
19*7f2fe78bSCy Schubert  * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY
20*7f2fe78bSCy Schubert  * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF
21*7f2fe78bSCy Schubert  * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
22*7f2fe78bSCy Schubert  * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
23*7f2fe78bSCy Schubert  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
24*7f2fe78bSCy Schubert  * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE
25*7f2fe78bSCy Schubert  * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR
26*7f2fe78bSCy Schubert  * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING
27*7f2fe78bSCy Schubert  * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
28*7f2fe78bSCy Schubert  * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF
29*7f2fe78bSCy Schubert  * SUCH DAMAGES.
30*7f2fe78bSCy Schubert  */
31*7f2fe78bSCy Schubert 
32*7f2fe78bSCy Schubert #ifndef _KRB5_INT_PKINIT_H
33*7f2fe78bSCy Schubert #define _KRB5_INT_PKINIT_H
34*7f2fe78bSCy Schubert 
35*7f2fe78bSCy Schubert /*
36*7f2fe78bSCy Schubert  * pkinit structures
37*7f2fe78bSCy Schubert  */
38*7f2fe78bSCy Schubert 
39*7f2fe78bSCy Schubert /* PKAuthenticator */
40*7f2fe78bSCy Schubert typedef struct _krb5_pk_authenticator {
41*7f2fe78bSCy Schubert     krb5_int32      cusec;  /* (0..999999) */
42*7f2fe78bSCy Schubert     krb5_timestamp  ctime;
43*7f2fe78bSCy Schubert     krb5_int32      nonce;  /* (0..4294967295) */
44*7f2fe78bSCy Schubert     krb5_checksum   paChecksum;
45*7f2fe78bSCy Schubert     krb5_data      *freshnessToken;
46*7f2fe78bSCy Schubert } krb5_pk_authenticator;
47*7f2fe78bSCy Schubert 
48*7f2fe78bSCy Schubert /* AlgorithmIdentifier */
49*7f2fe78bSCy Schubert typedef struct _krb5_algorithm_identifier {
50*7f2fe78bSCy Schubert     krb5_data algorithm;      /* OID */
51*7f2fe78bSCy Schubert     krb5_data parameters; /* Optional */
52*7f2fe78bSCy Schubert } krb5_algorithm_identifier;
53*7f2fe78bSCy Schubert 
54*7f2fe78bSCy Schubert /** AuthPack from RFC 4556*/
55*7f2fe78bSCy Schubert typedef struct _krb5_auth_pack {
56*7f2fe78bSCy Schubert     krb5_pk_authenticator       pkAuthenticator;
57*7f2fe78bSCy Schubert     krb5_data                   clientPublicValue; /* Optional */
58*7f2fe78bSCy Schubert     krb5_algorithm_identifier   **supportedCMSTypes; /* Optional */
59*7f2fe78bSCy Schubert     krb5_data                   clientDHNonce; /* Optional */
60*7f2fe78bSCy Schubert     krb5_data                   **supportedKDFs; /* OIDs of KDFs; OPTIONAL */
61*7f2fe78bSCy Schubert } krb5_auth_pack;
62*7f2fe78bSCy Schubert 
63*7f2fe78bSCy Schubert /* ExternalPrincipalIdentifier */
64*7f2fe78bSCy Schubert typedef struct _krb5_external_principal_identifier {
65*7f2fe78bSCy Schubert     krb5_data subjectName; /* Optional */
66*7f2fe78bSCy Schubert     krb5_data issuerAndSerialNumber; /* Optional */
67*7f2fe78bSCy Schubert     krb5_data subjectKeyIdentifier; /* Optional */
68*7f2fe78bSCy Schubert } krb5_external_principal_identifier;
69*7f2fe78bSCy Schubert 
70*7f2fe78bSCy Schubert /* PA-PK-AS-REQ (rfc4556 -- PA TYPE 16) */
71*7f2fe78bSCy Schubert typedef struct _krb5_pa_pk_as_req {
72*7f2fe78bSCy Schubert     krb5_data signedAuthPack;
73*7f2fe78bSCy Schubert     krb5_external_principal_identifier **trustedCertifiers; /* Optional array */
74*7f2fe78bSCy Schubert     krb5_data kdcPkId; /* Optional */
75*7f2fe78bSCy Schubert } krb5_pa_pk_as_req;
76*7f2fe78bSCy Schubert 
77*7f2fe78bSCy Schubert /** Pkinit DHRepInfo */
78*7f2fe78bSCy Schubert typedef struct _krb5_dh_rep_info {
79*7f2fe78bSCy Schubert     krb5_data dhSignedData;
80*7f2fe78bSCy Schubert     krb5_data serverDHNonce; /* Optional */
81*7f2fe78bSCy Schubert     krb5_data *kdfID; /* OID of selected KDF OPTIONAL */
82*7f2fe78bSCy Schubert } krb5_dh_rep_info;
83*7f2fe78bSCy Schubert 
84*7f2fe78bSCy Schubert /* KDCDHKeyInfo */
85*7f2fe78bSCy Schubert typedef struct _krb5_kdc_dh_key_info {
86*7f2fe78bSCy Schubert     krb5_data       subjectPublicKey; /* BIT STRING */
87*7f2fe78bSCy Schubert     krb5_int32      nonce;  /* (0..4294967295) */
88*7f2fe78bSCy Schubert     krb5_timestamp  dhKeyExpiration; /* Optional */
89*7f2fe78bSCy Schubert } krb5_kdc_dh_key_info;
90*7f2fe78bSCy Schubert 
91*7f2fe78bSCy Schubert /* ReplyKeyPack */
92*7f2fe78bSCy Schubert typedef struct _krb5_reply_key_pack {
93*7f2fe78bSCy Schubert     krb5_keyblock   replyKey;
94*7f2fe78bSCy Schubert     krb5_checksum   asChecksum;
95*7f2fe78bSCy Schubert } krb5_reply_key_pack;
96*7f2fe78bSCy Schubert 
97*7f2fe78bSCy Schubert /* PA-PK-AS-REP (rfc4556 -- PA TYPE 17) */
98*7f2fe78bSCy Schubert typedef struct _krb5_pa_pk_as_rep {
99*7f2fe78bSCy Schubert     enum krb5_pa_pk_as_rep_selection {
100*7f2fe78bSCy Schubert         choice_pa_pk_as_rep_UNKNOWN = -1,
101*7f2fe78bSCy Schubert         choice_pa_pk_as_rep_dhInfo = 0,
102*7f2fe78bSCy Schubert         choice_pa_pk_as_rep_encKeyPack = 1
103*7f2fe78bSCy Schubert     } choice;
104*7f2fe78bSCy Schubert     union krb5_pa_pk_as_rep_choices {
105*7f2fe78bSCy Schubert         krb5_dh_rep_info    dh_Info;
106*7f2fe78bSCy Schubert         krb5_data           encKeyPack;
107*7f2fe78bSCy Schubert     } u;
108*7f2fe78bSCy Schubert } krb5_pa_pk_as_rep;
109*7f2fe78bSCy Schubert 
110*7f2fe78bSCy Schubert /* SP80056A OtherInfo, for pkinit algorithm agility */
111*7f2fe78bSCy Schubert typedef struct _krb5_sp80056a_other_info {
112*7f2fe78bSCy Schubert     krb5_algorithm_identifier algorithm_identifier;
113*7f2fe78bSCy Schubert     krb5_principal  party_u_info;
114*7f2fe78bSCy Schubert     krb5_principal  party_v_info;
115*7f2fe78bSCy Schubert     krb5_data supp_pub_info;
116*7f2fe78bSCy Schubert } krb5_sp80056a_other_info;
117*7f2fe78bSCy Schubert 
118*7f2fe78bSCy Schubert /* PkinitSuppPubInfo, for pkinit algorithm agility */
119*7f2fe78bSCy Schubert typedef struct _krb5_pkinit_supp_pub_info {
120*7f2fe78bSCy Schubert     krb5_enctype      enctype;
121*7f2fe78bSCy Schubert     krb5_data         as_req;
122*7f2fe78bSCy Schubert     krb5_data         pk_as_rep;
123*7f2fe78bSCy Schubert } krb5_pkinit_supp_pub_info;
124*7f2fe78bSCy Schubert 
125*7f2fe78bSCy Schubert /*
126*7f2fe78bSCy Schubert  * Begin "asn1.h"
127*7f2fe78bSCy Schubert  */
128*7f2fe78bSCy Schubert 
129*7f2fe78bSCy Schubert /*************************************************************************
130*7f2fe78bSCy Schubert  * Prototypes for pkinit asn.1 encode routines
131*7f2fe78bSCy Schubert  *************************************************************************/
132*7f2fe78bSCy Schubert 
133*7f2fe78bSCy Schubert krb5_error_code
134*7f2fe78bSCy Schubert encode_krb5_pa_pk_as_req(const krb5_pa_pk_as_req *rep, krb5_data **code);
135*7f2fe78bSCy Schubert 
136*7f2fe78bSCy Schubert krb5_error_code
137*7f2fe78bSCy Schubert encode_krb5_pa_pk_as_rep(const krb5_pa_pk_as_rep *rep, krb5_data **code);
138*7f2fe78bSCy Schubert 
139*7f2fe78bSCy Schubert krb5_error_code
140*7f2fe78bSCy Schubert encode_krb5_auth_pack(const krb5_auth_pack *rep, krb5_data **code);
141*7f2fe78bSCy Schubert 
142*7f2fe78bSCy Schubert krb5_error_code
143*7f2fe78bSCy Schubert encode_krb5_kdc_dh_key_info(const krb5_kdc_dh_key_info *rep, krb5_data **code);
144*7f2fe78bSCy Schubert 
145*7f2fe78bSCy Schubert krb5_error_code
146*7f2fe78bSCy Schubert encode_krb5_reply_key_pack(const krb5_reply_key_pack *, krb5_data **code);
147*7f2fe78bSCy Schubert 
148*7f2fe78bSCy Schubert krb5_error_code
149*7f2fe78bSCy Schubert encode_krb5_td_trusted_certifiers(krb5_external_principal_identifier *const *,
150*7f2fe78bSCy Schubert                                   krb5_data **code);
151*7f2fe78bSCy Schubert 
152*7f2fe78bSCy Schubert krb5_error_code
153*7f2fe78bSCy Schubert encode_krb5_td_dh_parameters(krb5_algorithm_identifier *const *,
154*7f2fe78bSCy Schubert                              krb5_data **code);
155*7f2fe78bSCy Schubert 
156*7f2fe78bSCy Schubert krb5_error_code
157*7f2fe78bSCy Schubert encode_krb5_sp80056a_other_info(const krb5_sp80056a_other_info *,
158*7f2fe78bSCy Schubert                                 krb5_data **);
159*7f2fe78bSCy Schubert 
160*7f2fe78bSCy Schubert krb5_error_code
161*7f2fe78bSCy Schubert encode_krb5_pkinit_supp_pub_info(const krb5_pkinit_supp_pub_info *,
162*7f2fe78bSCy Schubert                                  krb5_data **);
163*7f2fe78bSCy Schubert 
164*7f2fe78bSCy Schubert /*************************************************************************
165*7f2fe78bSCy Schubert  * Prototypes for pkinit asn.1 decode routines
166*7f2fe78bSCy Schubert  *************************************************************************/
167*7f2fe78bSCy Schubert 
168*7f2fe78bSCy Schubert krb5_error_code
169*7f2fe78bSCy Schubert decode_krb5_pa_pk_as_req(const krb5_data *, krb5_pa_pk_as_req **);
170*7f2fe78bSCy Schubert 
171*7f2fe78bSCy Schubert krb5_error_code
172*7f2fe78bSCy Schubert decode_krb5_pa_pk_as_rep(const krb5_data *, krb5_pa_pk_as_rep **);
173*7f2fe78bSCy Schubert 
174*7f2fe78bSCy Schubert krb5_error_code
175*7f2fe78bSCy Schubert decode_krb5_auth_pack(const krb5_data *, krb5_auth_pack **);
176*7f2fe78bSCy Schubert 
177*7f2fe78bSCy Schubert krb5_error_code
178*7f2fe78bSCy Schubert decode_krb5_kdc_dh_key_info(const krb5_data *, krb5_kdc_dh_key_info **);
179*7f2fe78bSCy Schubert 
180*7f2fe78bSCy Schubert krb5_error_code
181*7f2fe78bSCy Schubert decode_krb5_principal_name(const krb5_data *, krb5_principal_data **);
182*7f2fe78bSCy Schubert 
183*7f2fe78bSCy Schubert krb5_error_code
184*7f2fe78bSCy Schubert decode_krb5_reply_key_pack(const krb5_data *, krb5_reply_key_pack **);
185*7f2fe78bSCy Schubert 
186*7f2fe78bSCy Schubert krb5_error_code
187*7f2fe78bSCy Schubert decode_krb5_td_trusted_certifiers(const krb5_data *,
188*7f2fe78bSCy Schubert                                   krb5_external_principal_identifier ***);
189*7f2fe78bSCy Schubert 
190*7f2fe78bSCy Schubert krb5_error_code
191*7f2fe78bSCy Schubert decode_krb5_td_dh_parameters(const krb5_data *, krb5_algorithm_identifier ***);
192*7f2fe78bSCy Schubert 
193*7f2fe78bSCy Schubert krb5_error_code
194*7f2fe78bSCy Schubert encode_krb5_enc_data(const krb5_enc_data *, krb5_data **);
195*7f2fe78bSCy Schubert 
196*7f2fe78bSCy Schubert krb5_error_code
197*7f2fe78bSCy Schubert encode_krb5_encryption_key(const krb5_keyblock *rep, krb5_data **code);
198*7f2fe78bSCy Schubert 
199*7f2fe78bSCy Schubert krb5_error_code
200*7f2fe78bSCy Schubert krb5_encrypt_helper(krb5_context context, const krb5_keyblock *key,
201*7f2fe78bSCy Schubert                     krb5_keyusage keyusage, const krb5_data *plain,
202*7f2fe78bSCy Schubert                     krb5_enc_data *cipher);
203*7f2fe78bSCy Schubert 
204*7f2fe78bSCy Schubert #endif /* _KRB5_INT_PKINIT_H */
205