summaryrefslogtreecommitdiff
path: root/cp/secu/secu.h
blob: b2cd417dfea4f0ee0d1c5e9a83e521614dae4346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/secu/seculib.h
 * \brief   All functions related to keys, protocolrun and security
 * \ingroup cp_secu
 */

#ifndef seculib__h__
#define seculib__h__

#include <stdio.h>
#include <stdlib.h>

#include "cp/secu/inc/secu_types.h"
#include "cp/secu/inc/secu_pbkdf1.h"
#include "cp/secu/inc/secu_p_run.h"

/**
 * initialize the secu module
 * \param  p_sec  ref to the struct
 */
void 
secu_init (sec_t *p_sec);

/**
 * hash password
 * \param pwd_type      the password type (DPW, NMK, NPW)
 * \param in            password to hash
 * \param key           obtained key from password
 * \return error code or 0 if success
 */
E_ErrCode 
secu_hash (pwd_type_t pwd_type, u8 in[], u8 out[]);

/**
 * AES key generation
 * \param key           generated key, AES_KEY_SIZE (in bytes)
 * \return              error code or 0 if success
 */
E_ErrCode 
secu_gen_aes_key (u8 key[]);

/**
 * return the ek for the given peks
 * \param peks          the peks
 * \param tei           tei of the station (only if peks == PEKS_DESTINATION_STA_DAK)
 * \return              the key
 */
aes_key_t *
secu_get_ek_from_peks(const peks_t peks, const tei_t tei);

void
secu_set_sta_s_dak(const tei_t, const aes_key_t dak);


#endif