Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
scp.h
Go to the documentation of this file.
1
/*
2
* Copyright 2015-2018 Yubico AB
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef SCP_H
18
#define SCP_H
19
20
#include <
stdint.h
>
21
#include <stdbool.h>
22
23
// Data derivation constants
24
#define SCP_CARD_CRYPTOGRAM 0x00
25
#define SCP_HOST_CRYPTOGRAM 0x01
26
27
#define SCP_CARD_CHALLENGE 0x02
28
29
#define SCP_S_ENC_DERIVATION 0x04
30
#define SCP_S_MAC_DERIVATION 0x06
31
#define SCP_S_RMAC_DERIVATION 0x07
32
33
// Lengths
34
#define AES_128_KEY_LEN 16
35
#define AES_192_KEY_LEN 24
36
#define AES_256_KEY_LEN 32
37
#define SCP_KEY_LEN (AES_128_KEY_LEN)
38
#define SCP_PRF_LEN 16
// One AES block
39
40
#define SCP_CARD_CHAL_LEN 8
41
#define SCP_HOST_CHAL_LEN 8
42
43
#define SCP_CARD_CRYPTO_LEN 8
44
#define SCP_HOST_CRYPTO_LEN 8
45
46
#define SCP_MAC_LEN 8
47
48
#define SCP_CONTEXT_LEN 16
49
50
#define SCP_AUTHKEY_ID_LEN 2
51
52
#define SCP_MSG_BUF_SIZE 2048
53
54
// Message
55
#pragma pack(push, 1)
56
union
_Msg
{
57
struct
{
58
uint8_t
cmd
;
59
uint16_t
len
;
60
uint8_t
data[
SCP_MSG_BUF_SIZE
];
61
}
st
;
62
uint8_t
raw
[3 +
SCP_MSG_BUF_SIZE
];
63
};
64
#pragma pack(pop)
65
66
typedef
union
_Msg
Msg
;
67
68
typedef
struct
{
69
uint8_t
sid
;
70
uint8_t
s_enc[
SCP_KEY_LEN
];
71
uint8_t
s_mac[
SCP_KEY_LEN
];
72
uint8_t
s_rmac[
SCP_KEY_LEN
];
73
uint8_t
mac_chaining_value[
SCP_PRF_LEN
];
74
uint8_t
ctr[
SCP_PRF_LEN
];
75
bool
in_use
;
76
bool
authenticated
;
77
}
Scp_ctx
;
78
79
#endif
SCP_KEY_LEN
#define SCP_KEY_LEN
Definition
scp.h:37
SCP_PRF_LEN
#define SCP_PRF_LEN
Definition
scp.h:38
SCP_MSG_BUF_SIZE
#define SCP_MSG_BUF_SIZE
Definition
scp.h:52
stdint.h
uint16_t
unsigned short uint16_t
Definition
stdint.h:125
uint8_t
unsigned char uint8_t
Definition
stdint.h:124
Scp_ctx
Definition
scp.h:68
Scp_ctx::in_use
bool in_use
Definition
scp.h:75
Scp_ctx::authenticated
bool authenticated
Definition
scp.h:76
Scp_ctx::sid
uint8_t sid
Definition
scp.h:69
_Msg
Definition
scp.h:56
_Msg::len
uint16_t len
Definition
scp.h:59
_Msg::st
struct _Msg::@103 st
_Msg::cmd
uint8_t cmd
Definition
scp.h:58
_Msg::raw
uint8_t raw[3+SCP_MSG_BUF_SIZE]
Definition
scp.h:62
libraries
yubihsm
lib
scp.h
Generated by
1.12.0