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)
64#pragma pack(pop)
65
66typedef union _Msg Msg;
67
68typedef struct {
73 uint8_t mac_chaining_value[SCP_PRF_LEN];
75 bool in_use;
77} Scp_ctx;
78
79#endif
#define SCP_KEY_LEN
Definition scp.h:37
#define SCP_PRF_LEN
Definition scp.h:38
#define SCP_MSG_BUF_SIZE
Definition scp.h:52
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
Definition scp.h:68
bool in_use
Definition scp.h:75
bool authenticated
Definition scp.h:76
uint8_t sid
Definition scp.h:69
Definition scp.h:56
uint16_t len
Definition scp.h:59
struct _Msg::@103 st
uint8_t cmd
Definition scp.h:58
uint8_t raw[3+SCP_MSG_BUF_SIZE]
Definition scp.h:62