Debian Codegraph @

internal/rc2/rc2_test.go

raw symbols SCIP
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package rc2scip-go gomod software.sslmate.com/src/go-pkcs12 . `software.sslmate.com/src/go-pkcs12/internal/rc2`/
6
7 import (
8 "bytesscip-go gomod github.com/golang/go/src go1.19 bytes/"
9 "encoding/hexscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/"
10 "testingscip-go gomod github.com/golang/go/src go1.19 testing/"
11 )
12
13 func TestEncryptDecryptscip-go gomod software.sslmate.com/src/go-pkcs12 . `software.sslmate.com/src/go-pkcs12/internal/rc2`/TestEncryptDecrypt().(t *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Tscip-go gomod github.com/golang/go/src go1.19 testing/T#) {
14 // TODO(dgryski): add the rest of the test vectors from the RFC
15 var tests = []struct {
16 key string
17 plain string
18 cipher string
19 t1 int
20 }{
21 {
22 "0000000000000000",
23 "0000000000000000",
24 "ebb773f993278eff",
25 63,
26 },
27 {
28 "ffffffffffffffff",
29 "ffffffffffffffff",
30 "278b27e42e2f0d49",
31 64,
32 },
33 {
34 "3000000000000000",
35 "1000000000000001",
36 "30649edf9be7d2c2",
37 64,
38 },
39 {
40 "88",
41 "0000000000000000",
42 "61a8a244adacccf0",
43 64,
44 },
45 {
46 "88bca90e90875a",
47 "0000000000000000",
48 "6ccf4308974c267f",
49 64,
50 },
51 {
52 "88bca90e90875a7f0f79c384627bafb2",
53 "0000000000000000",
54 "1a807d272bbe5db1",
55 64,
56 },
57 {
58 "88bca90e90875a7f0f79c384627bafb2",
59 "0000000000000000",
60 "2269552ab0f85ca6",
61 128,
62 },
63 {
64 "88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e",
65 "0000000000000000",
66 "5b78d3a43dfff1f1",
67 129,
68 },
69 }
70
71 for _, tt := range tests {
72 k, _ := hexscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/DecodeString().(tt.key)
73 p, _ := hexscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/DecodeString().(tt.plain)
74 c, _ := hexscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.19 `encoding/hex`/DecodeString().(tt.cipher)
75
76 b, _ := Newscip-go gomod software.sslmate.com/src/go-pkcs12 . `software.sslmate.com/src/go-pkcs12/internal/rc2`/New().(k, tt.t1)
77
78 var dst [8]byte
79
80 b.Encryptscip-go gomod github.com/golang/go/src go1.19 `crypto/cipher`/Block#Encrypt().(dst[:], p)
81
82 if !bytesscip-go gomod github.com/golang/go/src go1.19 bytes/.Equalscip-go gomod github.com/golang/go/src go1.19 bytes/Equal().(dst[:], c) {
83 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("encrypt failed: got % 2x wanted % 2x\n", dst, c)
84 }
85
86 b.Decryptscip-go gomod github.com/golang/go/src go1.19 `crypto/cipher`/Block#Decrypt().(dst[:], c)
87
88 if !bytesscip-go gomod github.com/golang/go/src go1.19 bytes/.Equalscip-go gomod github.com/golang/go/src go1.19 bytes/Equal().(dst[:], p) {
89 t.Errorfscip-go gomod github.com/golang/go/src go1.19 testing/common#Errorf().("decrypt failed: got % 2x wanted % 2x\n", dst, p)
90 }
91 }
92 }