~sircmpwn/hare-ssh

hare-ssh/net/ssh/agent/types.ha -rw-r--r-- 3.3 KiB
c6a39e37Armin Preiml harden against "compromise via lattices" 29 days ago
                                                                                
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
use format::ssh;

// SSH agent message types
export type messagetype = enum u8 {
	// Client requests
	REQUEST_IDENTITIES = 11,
	SIGN_REQUEST = 13,
	ADD_IDENTITY = 17,
	REMOVE_IDENTITY = 18,
	REMOVE_ALL_IDENTITIES = 19,
	ADD_ID_CONSTRAINED = 25,
	ADD_SMARTCARD_KEY = 20,
	REMOVE_SMARTCARD_KEY = 21,
	LOCK = 22,
	UNLOCK = 23,
	ADD_SMARTCARD_KEY_CONSTRAINED = 26,
	EXTENSION = 27,

	// Server responses
	FAILURE = 5,
	SUCCESS = 6,
	EXTENSION_FAILURE = 28,
	IDENTITIES_ANSWER = 12,
	SIGN_RESPONSE = 14,
};

// SSH agent constraint identifiers
export type constrainttype = enum u8 {
	CONSTRAIN_LIFETIME = 1,
	CONSTRAIN_CONFIRM = 2,
	CONSTRAIN_EXTENSION = 3,
};

// SSH agent signature flags
export type sigflag = enum u32 {
	RSA_SHA2_256 = 2,
	RSA_SHA2_512 = 4,
};

// An SSH agent message.
export type message = (
	agent_success |
	agent_failure |
	add_identity |
	add_id_constrained |
	remove_all_identities |
	remove_identity |
	remove_smartcard_key |
	request_identities |
	identities_answer |
	sign_request |
	sign_response |
	lock |
	unlock |
	extension |
	extension_failure
);

// The [[messagetype::SUCCESS]] message.
export type agent_success = void;

// The [[messagetype::FAILURE]] message.
export type agent_failure = void;

// The [[messagetype::EXTENSION_FAILURE]] message.
export type extension_failure = void;

// The [[messagetype::ADD_IDENTITY]] message.
export type add_identity = struct {
	keytype: str,
	key: *ssh::key,
	comment: str,
};

// The [[messagetype::ADD_ID_CONSTRAINED]] message.
export type add_id_constrained = struct {
	keytype: str,
	key: *ssh::key,
	comment: str,
	constraint: []constraint,
};

// The [[messagetype::ADD_SMARTCARD_KEY]] message.
export type add_smartcard_key = struct {
	id: str,
	pin: str,
	constraints: []constraint,
};

// The [[messagetype::REMOVE_ALL_IDENTITIES]] message.
export type remove_all_identities = void;

// The [[messagetype::REMOVE_IDENTITY]] message.
export type remove_identity = struct {
	blob: []u8,
};

// The [[messagetype::REMOVE_SMARTCARD_KEY]] message.
export type remove_smartcard_key = struct {
	id: str,
	pin: str,
};

// The [[messagetype::REQUEST_IDENTITIES]] message.
export type request_identities = void;

// The [[messagetype::IDENTITIES_ANSWER]] message.
export type identities_answer = []identity;

// An identity for use with [[identities_answer]].
export type identity = struct {
	pubkey: []u8,
	comment: str,
};

// The [[messagetype::SIGN_REQUEST]] message.
export type sign_request = struct {
	key: []u8,
	data: []u8,
	flags: sigflag,
};

// The [[messagetype::SIGN_RESPONSE]] message.
export type sign_response = struct {
	signature: []u8,
};

// The [[messagetype::LOCK]] message.
export type lock = struct {
	passphrase: []u8,
};

// The [[messagetype::UNLOCK]] message.
export type unlock = struct {
	passphrase: []u8,
};

// The [[messagetype::EXTENSION]] message.
export type extension = struct {
	extype: str,
	payload: []u8,
};

// A key constraint.
export type constraint = struct {
	ctype: constrainttype,
	constraint: (lifetime | confirmation | constraintext),
};

// The SSH_AGENT_CONSTRAIN_LIFETIME constraint.
export type lifetime = struct {
	seconds: u32,
};

// The SSH_AGENT_CONSTRAIN_CONFIRM.
export type confirmation = void;

// The SSH_AGENT_CONSTRAIN_EXTENSION constraint.
export type constraintext = struct {
	exname: str,
	payload: []u8,
};