blob: 845c2d8a1693e4676bf2291a39546a38762cd724 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
3 * Copyright (c) 2017 Intel Corporation
4 * Copyright (c) 2019, Infosys Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef __STAGE1_SEC_H_
20#define __STAGE1_SEC_H_
21
22/* Common to HSS and MME */
23#define AIA_RES_SIZE 8
24#define AIA_AUTS_SIZE 14
25#define AIA_AUTN_SIZE 16
26#define AIA_RAND_SIZE 16
27#define AIA_KASME_SIZE 32
28#define AIA_NEXT_HOP_SIZE 32
29
30#define HASH_SALT_LEN 7
31#define HASH_KEY_LEN 512
32
33#define NAS_INT_KEY_SIZE 16
34#define KENB_SIZE 32
35#define HMAC_SIZE 1024
36
37typedef struct RAND {
38 unsigned char len;
39 unsigned char val[AIA_RAND_SIZE];
40} RAND;
41
42typedef struct XRES {
43 unsigned char len;
44 unsigned char val[AIA_RES_SIZE];
45} XRES;
46
47typedef struct AUTS {
48 unsigned char len;
49 unsigned char val[AIA_AUTS_SIZE];
50} AUTS;
51
52typedef struct AUTN {
53 unsigned char len;
54 unsigned char val[AIA_AUTN_SIZE];
55} AUTN;
56
57typedef struct KASME {
58 unsigned char len;
59 unsigned char val[AIA_KASME_SIZE];
60} KASME;
61
62/**
63 * @brief Create integrity key
64 * @param[in] kasme key
65 * @param[out] int_key generated integrity key
66 * @return void
67 */
68void create_integrity_key(unsigned char *kasme, unsigned char *int_key);
69
70/**
71 * @brief Create eNodeB key to exchange in init ctx message
72 * @param [in]kasme key
73 * @param [out]kenb_key output the generated key
74 * @return void
75 */
76void create_kenb_key(unsigned char *kasme, unsigned char *kenb_key,
77 unsigned int seq_no);
78
79
80void calculate_hmac_sha256(const unsigned char *input_data,
81 int input_data_len, const unsigned char *key,
82 int key_length, void *output, unsigned int *out_len);
83
84#endif