-
Notifications
You must be signed in to change notification settings - Fork 0
/
hss_test.go
236 lines (219 loc) · 13 KB
/
hss_test.go
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// Copyright (C) 2020, ISARA Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build cgo
package iqrcrypto
import (
"crypto/rand"
b64 "encoding/base64"
"encoding/pem"
"log"
"testing"
)
var msg = []byte("Hello, world!\n\n")
var hssPubKey = `
-----BEGIN PUBLIC KEY-----
MFAwDQYLKoZIhvcNAQkQAxEDPwAEPAAAAAUAAAAGAAAABOfk0r5lF1loeF7iMu3h
GyQE4aC6lzFwE05PLqYy42hIUvLKjrXwzTS8yzhE0wua5w==
-----END PUBLIC KEY-----
`
var hssSignature = `
A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GUJupaUsbcmJ31QMA5hlAHYmYmofF6rk
`
func TestImportExportHSS(t *testing.T) {
var ctx *IqrContext
var rng *IqrRNG
err := IqrCreateContext(&ctx)
if err != nil {
t.Fatalf("IqrCreateContext ret is: %s\n", err)
}
err = IqrInitRNG(&ctx, &rng, rand.Reader)
if err != nil {
t.Fatalf("IqrInitRNG ret is: %s\n", err)
}
// Convert pub key PEM to DER
block, _ := pem.Decode([]byte(hssPubKey))
if block == nil || block.Type != "PUBLIC KEY" {
log.Fatal("failed to decode PEM block containing HSS public key")
}
sig, err := b64.StdEncoding.DecodeString(hssSignature)
if err != nil {
t.Fatalf("Failed to base64 decode signature\n")
}
err = IqrHashRegisterCallbacks(ctx, IQR_HASHALGO_SHA2_256, IQR_HASH_DEFAULT_SHA2_256)
if err != nil {
t.Fatalf("IqrHashRegisterCallbacks ret is: %s\n", err)
}
var params *IqrHSSParams = nil
err = IqrHSSCreateParamsFromSignature(ctx, sig, int64(len(sig)), ¶ms)
if err != nil {
t.Fatalf("IqrHSSCreateParamsFromSignature ret is: %s\n", err)
}
// Import public key
var publicKey *IqrHSSPublicKey = nil
err = IqrHSSImportPublicKeyFromASN1(ctx, block.Bytes, int64(len(block.Bytes)), &publicKey, params)
if err != nil {
t.Fatalf("IqrHSSImportPublicKey error: %s\n", err)
}
err = IqrHSSVerify(publicKey, msg, int64(len(msg)), sig, int64(len(sig)))
if err != nil {
t.Fatalf("IqrHSSVerify failed: %s\n", err)
}
err = IqrRNGDestroy(&rng)
if err != nil {
t.Fatalf("IqrRNGDestroy ret is: %s\n", err)
}
err = IqrDestroyContext(&ctx)
if err != nil {
t.Fatalf("IqrDestroyContext ret is: %s\n", err)
}
}