1 /*
2  * Copyright (c) 2003 Sun Microsystems, Inc.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistribution of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistribution in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * Neither the name of Sun Microsystems, Inc. or the names of
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * This software is provided "AS IS," without a warranty of any kind.
20  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23  * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
24  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25  * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT WILL
26  * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27  * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31  */
32 
33 #ifndef IPMI_LANPLUS_CRYPT_H
34 #define IPMI_LANPLUS_CRYPT_H
35 
36 #include <ipmitool/ipmi_intf.h>
37 
38 /*
39  * See the implementation file for documentation
40  * ipmi_intf can be used for oem specific implementations
41  * e.g. if (ipmi_oem_active(intf, "OEM_XYZ"))
42  */
43 
44 int lanplus_rakp2_hmac_matches(const struct ipmi_session * session,
45 							   const uint8_t             * hmac,
46 							   struct ipmi_intf          * intf);
47 int lanplus_rakp4_hmac_matches(const struct ipmi_session * session,
48 							   const uint8_t             * hmac,
49 							   struct ipmi_intf          * intf);
50 int lanplus_generate_rakp3_authcode(uint8_t                      * buffer,
51 									const struct ipmi_session * session,
52 									uint32_t                  * auth_length,
53 									struct ipmi_intf          * intf);
54 int lanplus_generate_sik(struct ipmi_session * session, struct ipmi_intf * intf);
55 int lanplus_generate_k1(struct ipmi_session * session);
56 int lanplus_generate_k2(struct ipmi_session * session);
57 int lanplus_encrypt_payload(uint8_t         crypt_alg,
58 							const uint8_t * key,
59 							const uint8_t * input,
60 							uint32_t          input_length,
61 							uint8_t       * output,
62 							uint16_t      * bytesWritten);
63 int lanplus_decrypt_payload(uint8_t         crypt_alg,
64 							const uint8_t * key,
65 							const uint8_t * input,
66 							uint32_t          input_length,
67 							uint8_t       * output,
68 							uint16_t      * payload_size);
69 int lanplus_has_valid_auth_code(struct ipmi_rs * rs,
70 								struct ipmi_session * session);
71 
72 
73 
74 
75 #endif /* IPMI_LANPLUS_CRYPT_H  */
76