MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestCipheringErrors

Function TestCipheringErrors

crypto/cipher_test.go:53–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestCipheringErrors(t *testing.T) {
54 privkey, _, err := asymmetric.GenSecp256k1KeyPair()
55 if err != nil {
56 t.Fatal("failed to generate private key")
57 }
58
59 tests1 := []struct {
60 ciphertext []byte // input ciphertext
61 }{
62 {bytes.Repeat([]byte{0x00}, 133)}, // errInputTooShort
63 {bytes.Repeat([]byte{0x00}, 134)}, // errUnsupportedCurve
64 {bytes.Repeat([]byte{0x02, 0xCA}, 134)}, // errInvalidXLength
65 {bytes.Repeat([]byte{0x02, 0xCA, 0x00, 0x20}, 134)}, // errInvalidYLength
66 {[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // IV
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x02, 0xCA, 0x00, 0x20, // curve and X length
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // X
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x20, // Y length
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Y
75 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ciphertext
79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // MAC
81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 }}, // invalid pubkey
85 {[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // IV
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x02, 0xCA, 0x00, 0x20, // curve and X length
88 0x11, 0x5C, 0x42, 0xE7, 0x57, 0xB2, 0xEF, 0xB7, // X
89 0x67, 0x1C, 0x57, 0x85, 0x30, 0xEC, 0x19, 0x1A,
90 0x13, 0x59, 0x38, 0x1E, 0x6A, 0x71, 0x12, 0x7A,
91 0x9D, 0x37, 0xC4, 0x86, 0xFD, 0x30, 0xDA, 0xE5,
92 0x00, 0x20, // Y length
93 0x7E, 0x76, 0xDC, 0x58, 0xF6, 0x93, 0xBD, 0x7E, // Y
94 0x70, 0x10, 0x35, 0x8C, 0xE6, 0xB1, 0x65, 0xE4,
95 0x83, 0xA2, 0x92, 0x10, 0x10, 0xDB, 0x67, 0xAC,
96 0x11, 0xB1, 0xB5, 0x1B, 0x65, 0x19, 0x53, 0xD2,
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ciphertext
98 // padding not aligned to 16 bytes
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // MAC
101 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
104 }}, // errInvalidPadding
105 {[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // IV
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x02, 0xCA, 0x00, 0x20, // curve and X length
108 0x11, 0x5C, 0x42, 0xE7, 0x57, 0xB2, 0xEF, 0xB7, // X
109 0x67, 0x1C, 0x57, 0x85, 0x30, 0xEC, 0x19, 0x1A,
110 0x13, 0x59, 0x38, 0x1E, 0x6A, 0x71, 0x12, 0x7A,

Callers

nothing calls this directly

Calls 5

GenSecp256k1KeyPairFunction · 0.92
DecryptAndCheckFunction · 0.85
RemovePKCSPaddingFunction · 0.85
FatalMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected