forked from gunnsth/pkcs7
-
Notifications
You must be signed in to change notification settings - Fork 7
/
sign_test.go
418 lines (376 loc) · 40.5 KB
/
sign_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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
package pkcs7
import (
"bytes"
"crypto/dsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
"encoding/pem"
"fmt"
"io/ioutil"
"log"
"math/big"
"os"
"os/exec"
"testing"
)
func TestSign(t *testing.T) {
content := []byte("Hello World")
sigalgs := []x509.SignatureAlgorithm{
x509.SHA1WithRSA,
x509.SHA256WithRSA,
x509.SHA512WithRSA,
x509.ECDSAWithSHA1,
x509.ECDSAWithSHA256,
x509.ECDSAWithSHA384,
x509.ECDSAWithSHA512,
}
for _, sigalgroot := range sigalgs {
rootCert, err := createTestCertificateByIssuer("PKCS7 Test Root CA", nil, sigalgroot, true)
if err != nil {
t.Fatalf("test %s: cannot generate root cert: %s", sigalgroot, err)
}
truststore := x509.NewCertPool()
truststore.AddCert(rootCert.Certificate)
for _, sigalginter := range sigalgs {
interCert, err := createTestCertificateByIssuer("PKCS7 Test Intermediate Cert", rootCert, sigalginter, true)
if err != nil {
t.Fatalf("test %s/%s: cannot generate intermediate cert: %s", sigalgroot, sigalginter, err)
}
var parents []*x509.Certificate
parents = append(parents, interCert.Certificate)
for _, sigalgsigner := range sigalgs {
signerCert, err := createTestCertificateByIssuer("PKCS7 Test Signer Cert", interCert, sigalgsigner, false)
if err != nil {
t.Fatalf("test %s/%s/%s: cannot generate signer cert: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
for _, testDetach := range []bool{false, true} {
log.Printf("test %s/%s/%s detached %t\n", sigalgroot, sigalginter, sigalgsigner, testDetach)
toBeSigned, err := NewSignedData(content)
if err != nil {
t.Fatalf("test %s/%s/%s: cannot initialize signed data: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
// Set the digest to match the end entity cert
signerDigest, _ := getDigestOIDForSignatureAlgorithm(signerCert.Certificate.SignatureAlgorithm)
toBeSigned.SetDigestAlgorithm(signerDigest)
if err := toBeSigned.AddSignerChain(signerCert.Certificate, *signerCert.PrivateKey, parents, SignerInfoConfig{}); err != nil {
t.Fatalf("test %s/%s/%s: cannot add signer: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
if testDetach {
toBeSigned.Detach()
}
signed, err := toBeSigned.Finish()
if err != nil {
t.Fatalf("test %s/%s/%s: cannot finish signing data: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: signed})
p7, err := Parse(signed)
if err != nil {
t.Fatalf("test %s/%s/%s: cannot parse signed data: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
if testDetach {
p7.Content = content
}
if !bytes.Equal(content, p7.Content) {
t.Errorf("test %s/%s/%s: content was not found in the parsed data:\n\tExpected: %s\n\tActual: %s", sigalgroot, sigalginter, sigalgsigner, content, p7.Content)
}
if err := p7.VerifyWithChain(truststore); err != nil {
t.Errorf("test %s/%s/%s: cannot verify signed data: %s", sigalgroot, sigalginter, sigalgsigner, err)
}
if !signerDigest.Equal(p7.Signers[0].DigestAlgorithm.Algorithm) {
t.Errorf("test %s/%s/%s: expected digest algorithm %q but got %q",
sigalgroot, sigalginter, sigalgsigner, signerDigest, p7.Signers[0].DigestAlgorithm.Algorithm)
}
}
}
}
}
}
func TestSignAndVerifyWithOpenSSL(t *testing.T) {
content := []byte("Hello World")
// write the content to a temp file
tmpContentFile, err := ioutil.TempFile("", "TestDSASignAndVerifyWithOpenSSL_content")
if err != nil {
t.Fatal(err)
}
ioutil.WriteFile(tmpContentFile.Name(), content, 0755)
block, _ := pem.Decode([]byte(dsaPublicCert))
if block == nil {
t.Fatal("failed to parse certificate PEM")
}
signerCert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
t.Fatal("failed to parse certificate: " + err.Error())
}
// write the signer cert to a temp file
tmpSignerCertFile, err := ioutil.TempFile("", "TestDSASignAndVerifyWithOpenSSL_signer")
if err != nil {
t.Fatal(err)
}
ioutil.WriteFile(tmpSignerCertFile.Name(), dsaPublicCert, 0755)
priv := dsa.PrivateKey{
PublicKey: dsa.PublicKey{Parameters: dsa.Parameters{P: fromHex("fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7"),
Q: fromHex("9760508F15230BCCB292B982A2EB840BF0581CF5"),
G: fromHex("F7E1A085D69B3DDECBBCAB5C36B857B97994AFBBFA3AEA82F9574C0B3D0782675159578EBAD4594FE67107108180B449167123E84C281613B7CF09328CC8A6E13C167A8B547C8D28E0A3AE1E2BB3A675916EA37F0BFA213562F1FB627A01243BCCA4F1BEA8519089A883DFE15AE59F06928B665E807B552564014C3BFECF492A"),
},
},
X: fromHex("7D6E1A3DD4019FD809669D8AB8DA73807CEF7EC1"),
}
toBeSigned, err := NewSignedData(content)
if err != nil {
t.Fatalf("test case: cannot initialize signed data: %s", err)
}
if err := toBeSigned.SignWithoutAttr(signerCert, &priv, SignerInfoConfig{}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
toBeSigned.Detach()
signed, err := toBeSigned.Finish()
if err != nil {
t.Fatalf("test case: cannot finish signing data: %s", err)
}
// write the signature to a temp file
tmpSignatureFile, err := ioutil.TempFile("", "TestDSASignAndVerifyWithOpenSSL_signature")
if err != nil {
t.Fatal(err)
}
ioutil.WriteFile(tmpSignatureFile.Name(), pem.EncodeToMemory(&pem.Block{Type: "PKCS7", Bytes: signed}), 0755)
// call openssl to verify the signature on the content using the root
opensslCMD := exec.Command("openssl", "smime", "-verify", "-noverify",
"-in", tmpSignatureFile.Name(), "-inform", "PEM",
"-content", tmpContentFile.Name())
out, err := opensslCMD.CombinedOutput()
if err != nil {
t.Fatalf("test case: openssl command failed with %s: %s", err, out)
}
os.Remove(tmpSignatureFile.Name()) // clean up
os.Remove(tmpContentFile.Name()) // clean up
os.Remove(tmpSignerCertFile.Name()) // clean up
}
func ExampleSignedData(t *testing.T) {
// generate a signing cert or load a key pair
cert, err := createTestCertificate(x509.SHA256WithRSA)
if err != nil {
t.Fatalf("Cannot create test certificates: %s", err)
}
// Initialize a SignedData struct with content to be signed
signedData, err := NewSignedData([]byte("Example data to be signed"))
if err != nil {
t.Fatalf("Cannot initialize signed data: %s", err)
}
// Add the signing cert and private key
if err := signedData.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
// Call Detach() is you want to remove content from the signature
// and generate an S/MIME detached signature
signedData.Detach()
// Finish() to obtain the signature bytes
detachedSignature, err := signedData.Finish()
if err != nil {
t.Fatalf("Cannot finish signing data: %s", err)
}
pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: detachedSignature})
}
func TestSignedDataWithContentType(t *testing.T) {
// generate a signing cert or load a key pair
cert, err := createTestCertificate(x509.SHA1WithRSA)
if err != nil {
t.Fatalf("Cannot create test certificates: %s", err)
}
// Initialize a SignedData struct with content to be signed
signedData, err := NewSignedDataWithContentType(asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 16, 1, 4}, []byte("Example data to be signed"))
if err != nil {
t.Fatalf("Cannot initialize signed data: %s", err)
}
// Add the signing cert and private key
if err := signedData.AddSignerNoChain(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
// Finish() to obtain the signature bytes
detachedSignature, err := signedData.Finish()
if err != nil {
fmt.Printf("Cannot finish signing data: %s", err)
}
pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: detachedSignature})
}
func TestUnmarshalSignedAttribute(t *testing.T) {
cert, err := createTestCertificate(x509.SHA512WithRSA)
if err != nil {
t.Fatal(err)
}
content := []byte("Hello World")
toBeSigned, err := NewSignedData(content)
if err != nil {
t.Fatalf("Cannot initialize signed data: %s", err)
}
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
testValue := "TestValue"
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}},
}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
signed, err := toBeSigned.Finish()
if err != nil {
t.Fatalf("Cannot finish signing data: %s", err)
}
p7, err := Parse(signed)
if err != nil {
t.Fatalf("Cannot parse signed data: %v", err)
}
var actual string
err = p7.UnmarshalSignedAttribute(oidTest, &actual)
if err != nil {
t.Fatalf("Cannot unmarshal test value: %s", err)
}
if testValue != actual {
t.Errorf("Attribute does not match test value\n\tExpected: %s\n\tActual: %s", testValue, actual)
}
}
func TestDegenerateCertificate(t *testing.T) {
cert, err := createTestCertificate(x509.SHA1WithRSA)
if err != nil {
t.Fatal(err)
}
deg, err := DegenerateCertificate(cert.Certificate.Raw)
if err != nil {
t.Fatal(err)
}
testOpenSSLParse(t, deg)
pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: deg})
}
// writes the cert to a temporary file and tests that openssl can read it.
func testOpenSSLParse(t *testing.T, certBytes []byte) {
tmpCertFile, err := ioutil.TempFile("", "testCertificate")
if err != nil {
t.Fatal(err)
}
defer os.Remove(tmpCertFile.Name()) // clean up
if _, err := tmpCertFile.Write(certBytes); err != nil {
t.Fatal(err)
}
opensslCMD := exec.Command("openssl", "pkcs7", "-inform", "der", "-in", tmpCertFile.Name())
_, err = opensslCMD.Output()
if err != nil {
t.Fatal(err)
}
if err := tmpCertFile.Close(); err != nil {
t.Fatal(err)
}
}
func fromHex(s string) *big.Int {
result, ok := new(big.Int).SetString(s, 16)
if !ok {
panic(s)
}
return result
}
func TestUnmarshal(t *testing.T) {
t.Log("itext")
testUnmarshal(t, `MIIcoQYJKoZIhvcNAQcCoIIckjCCHI4CAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGgggrOMIIE+DCCA+CgAwIBAgIQAQT/iaGBG48UxFc7nqJ5OTANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJCRTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTEpMCcGA1UEAxMgR2xvYmFsU2lnbiBBdGxhcyBSNiBBQVRMIENBIDIwMjAwHhcNMjEwNjE4MDk1NzQzWh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IQXc0J1vVx0pv/ZEoTjeD4JfwgnqdkQS3QoAtzVZzXi2YDRQVLhDimqvTwh3SdTFaj2UMtvgPPNjGCAp4wggKaAgEBMGcwVzELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExLTArBgNVBAMTJEdsb2JhbFNpZ24gQ0EgZm9yIEFBVEwgLSBTSEEzODQgLSBHNAIMFjeuHefw8VTHkN6gMAsGCWCGSAFlAwQCAaCCAQowGgYJKoZIhvcNAQkDMQ0GCyqGSIb3DQEJEAEEMBwGCSqGSIb3DQEJBTEPFw0yMTA2MjIwOTQwMDNaMC8GCSqGSIb3DQEJBDEiBCBcmSLAeYjMiwTGdaeVJ3mMaByztt+TYYN0GODACP9+RjCBnAYLKoZIhvcNAQkQAgwxgYwwgYkwgYYwgYMEFBf4NGBcPdR8vIOLirM+hNrx8cG1MGswW6RZMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMS0wKwYDVQQDEyRHbG9iYWxTaWduIENBIGZvciBBQVRMIC0gU0hBMzg0IC0gRzQCDBY3rh3n8PFUx5DeoDANBgkqhkiG9w0BAQsFAASCAQAjk6nw5SEPT+8XR6Tlp1/kYr/5nKmpTeJQeeFa/4nj+tszW6mjPf3Fbjjh2+BpYyhMcTPoEB18HkNh8Pjt1XCPgagt5iolD57qK17daQHYI3y3rm4+TGAZn+Gq8U+OUrqBk3G5efySAeaBJzfXuMg/FTB8JD2fEInGAqF78mR2i/gNGBeKOJWCkiuD+WuhJFjuC+9rIhb0BxhEMouugfGR0dKQQFDSYs0FSmoIy0QkkaQBe41NCrcf8P8rasgdXSgmh30EGZ+y4jqaaZGHbL242mF+SqLM9I9mX1IcY4oZioqmf0eAEVQ2vnwsSFYuy9oXcIS7WNEOFbKT+PlrLdKb`)
}
func testUnmarshal(t *testing.T, sig string) {
b, err := base64.StdEncoding.DecodeString(sig)
if err != nil {
t.Error(err)
t.FailNow()
}
var content contentInfo
_, err = asn1.Unmarshal(b, &content)
if err != nil {
t.Error(err)
t.FailNow()
}
t.Log(content.ContentType)
var inner signedData
_, err = asn1.Unmarshal(content.Content.Bytes, &inner)
if err != nil {
t.Error(err)
t.FailNow()
}
t.Logf("version: %d", inner.Version)
t.Log("digest algorithm:")
t.Log("==================")
for _, di := range inner.DigestAlgorithmIdentifiers {
t.Logf("\t %v: %v", di.Algorithm, di.Parameters)
}
t.Logf("content info: %v", inner.ContentInfo)
t.Log("==================")
t.Logf("\tcontent type: %v", inner.ContentInfo.ContentType)
t.Logf("\tcontent: %v", inner.ContentInfo.Content)
t.Log("certificates:")
t.Log("==================")
certs, err := inner.Certificates.Parse()
if err == nil {
for _, cert := range certs {
t.Logf("\tissuer: %v", cert.Issuer)
t.Logf("\tserialNumber: %v", cert.SerialNumber)
t.Logf("\tCA: %v", cert.IsCA)
}
}
t.Log("CRL:")
t.Log("==================")
for _, crl := range inner.CRLs {
t.Logf("\talgorithm: %v", crl.SignatureAlgorithm)
t.Logf("\tvalue: %v", crl.SignatureValue)
t.Logf("\ttbs: %v", crl.TBSCertList)
}
t.Log("signers", len(inner.SignerInfos))
t.Log("==================")
if len(inner.SignerInfos) > 0 {
si := inner.SignerInfos[0]
t.Logf("version: %d", si.Version)
t.Log("issuer:")
var issuer pkix.RDNSequence
_, err = asn1.Unmarshal(si.IssuerAndSerialNumber.IssuerName.FullBytes, &issuer)
if err != nil {
t.Logf("\terr: %v", err)
}
t.Logf("issuer: %v\n", issuer)
t.Logf("\tissuer Name: %v", string(si.IssuerAndSerialNumber.IssuerName.Bytes))
t.Logf("\tserial Number: %v", si.IssuerAndSerialNumber.SerialNumber)
t.Logf("\tdigest alg: %v", si.DigestAlgorithm)
t.Log("authentication attributes:")
for _, attr := range si.AuthenticatedAttributes {
t.Log("\toid", attr.Type)
if attr.Type.Equal(OIDAttributeContentType) {
var v asn1.ObjectIdentifier
if _, err := asn1.Unmarshal(attr.Value.Bytes, &v); err != nil {
t.Log("err", err)
continue
}
t.Logf("\tvalue: %v", v)
} else if attr.Type.Equal(OIDAttributeMessageDigest) {
t.Log("\tmessage digest:")
t.Log("\tvalue", string(attr.Value.Bytes))
} else if attr.Type.Equal(OIDAttributeSigningCertificateV2) {
var signingCert signingCertificateV2
if _, err := asn1.Unmarshal(attr.Value.Bytes, &signingCert); err != nil {
t.Log("err", err)
continue
}
t.Log("\tSigning Certificates:")
for _, cert := range signingCert.Certs {
t.Logf("\t\tHash Algoritm: %v", cert.HashAlgorithm)
t.Logf("\t\tCert hash: %v", string(cert.CertHash))
t.Logf("\t\tIssuer and Serial: %v", cert.IssuerSerial)
}
} else {
var test string
if _, err := asn1.Unmarshal(attr.Value.Bytes, &test); err == nil {
t.Log("\tvalue string:", test)
} else {
t.Log("\tvalue", attr.Value.Bytes)
}
}
}
t.Logf("encrypt algo: %v", si.DigestEncryptionAlgorithm)
}
t.Log("<=====================================>")
t.Log("<=====================================>")
}