Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / usb / host / dwc_common_port / dwc_crypto.h
1 /* =========================================================================
2  * $File: //dwh/usb_iip/dev/software/dwc_common_port_2/dwc_crypto.h $
3  * $Revision: #3 $
4  * $Date: 2010/09/28 $
5  * $Change: 1596182 $
6  *
7  * Synopsys Portability Library Software and documentation
8  * (hereinafter, "Software") is an Unsupported proprietary work of
9  * Synopsys, Inc. unless otherwise expressly agreed to in writing
10  * between Synopsys and you.
11  *
12  * The Software IS NOT an item of Licensed Software or Licensed Product
13  * under any End User Software License Agreement or Agreement for
14  * Licensed Product with Synopsys or any supplement thereto. You are
15  * permitted to use and redistribute this Software in source and binary
16  * forms, with or without modification, provided that redistributions
17  * of source code must retain this notice. You may not view, use,
18  * disclose, copy or distribute this file or any information contained
19  * herein except pursuant to this license grant from Synopsys. If you
20  * do not agree with this notice, including the disclaimer below, then
21  * you are not authorized to use the Software.
22  *
23  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
24  * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL
27  * SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
31  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
33  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
34  * DAMAGE.
35  * ========================================================================= */
36
37 #ifndef _DWC_CRYPTO_H_
38 #define _DWC_CRYPTO_H_
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /** @file
45  *
46  * This file contains declarations for the WUSB Cryptographic routines as
47  * defined in the WUSB spec.  They are only to be used internally by the DWC UWB
48  * modules.
49  */
50
51 #include "dwc_os.h"
52
53 int dwc_wusb_aes_encrypt(u8 *src, u8 *key, u8 *dst);
54
55 void dwc_wusb_cmf(u8 *key, u8 *nonce,
56                   char *label, u8 *bytes, int len, u8 *result);
57 void dwc_wusb_prf(int prf_len, u8 *key,
58                   u8 *nonce, char *label, u8 *bytes, int len, u8 *result);
59
60 /**
61  * The PRF-64 function described in section 6.5 of the WUSB spec.
62  *
63  * @param key, nonce, label, bytes, len, result  Same as for dwc_prf().
64  */
65 static inline void dwc_wusb_prf_64(u8 *key, u8 *nonce,
66                                    char *label, u8 *bytes, int len, u8 *result)
67 {
68         dwc_wusb_prf(64, key, nonce, label, bytes, len, result);
69 }
70
71 /**
72  * The PRF-128 function described in section 6.5 of the WUSB spec.
73  *
74  * @param key, nonce, label, bytes, len, result  Same as for dwc_prf().
75  */
76 static inline void dwc_wusb_prf_128(u8 *key, u8 *nonce,
77                                     char *label, u8 *bytes, int len, u8 *result)
78 {
79         dwc_wusb_prf(128, key, nonce, label, bytes, len, result);
80 }
81
82 /**
83  * The PRF-256 function described in section 6.5 of the WUSB spec.
84  *
85  * @param key, nonce, label, bytes, len, result  Same as for dwc_prf().
86  */
87 static inline void dwc_wusb_prf_256(u8 *key, u8 *nonce,
88                                     char *label, u8 *bytes, int len, u8 *result)
89 {
90         dwc_wusb_prf(256, key, nonce, label, bytes, len, result);
91 }
92
93
94 void dwc_wusb_fill_ccm_nonce(uint16_t haddr, uint16_t daddr, uint8_t *tkid,
95                                uint8_t *nonce);
96 void dwc_wusb_gen_nonce(uint16_t addr,
97                           uint8_t *nonce);
98
99 void dwc_wusb_gen_key(uint8_t *ccm_nonce, uint8_t *mk,
100                         uint8_t *hnonce, uint8_t *dnonce,
101                         uint8_t *kck, uint8_t *ptk);
102
103
104 void dwc_wusb_gen_mic(uint8_t *ccm_nonce, uint8_t
105                         *kck, uint8_t *data, uint8_t *mic);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif /* _DWC_CRYPTO_H_ */