1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- use crate :: crypto:: CryptoError ;
4
+ use crate :: crypto:: packet_protection ;
5
5
use s2n_codec:: encoder:: scatter;
6
6
7
7
/// A trait for crypto keys
@@ -12,15 +12,15 @@ pub trait Key: Send {
12
12
packet_number : u64 ,
13
13
header : & [ u8 ] ,
14
14
payload : & mut [ u8 ] ,
15
- ) -> Result < ( ) , CryptoError > ;
15
+ ) -> Result < ( ) , packet_protection :: Error > ;
16
16
17
17
/// Encrypt a payload
18
18
fn encrypt (
19
19
& self ,
20
20
packet_number : u64 ,
21
21
header : & [ u8 ] ,
22
22
payload : & mut scatter:: Buffer ,
23
- ) -> Result < ( ) , CryptoError > ;
23
+ ) -> Result < ( ) , packet_protection :: Error > ;
24
24
25
25
/// Length of the appended tag
26
26
fn tag_len ( & self ) -> usize ;
@@ -37,8 +37,9 @@ pub trait Key: Send {
37
37
#[ cfg( any( test, feature = "testing" ) ) ]
38
38
pub mod testing {
39
39
use crate :: crypto:: {
40
+ packet_protection,
40
41
retry:: { IntegrityTag , INTEGRITY_TAG_LEN } ,
41
- scatter, CryptoError , HandshakeHeaderKey , HandshakeKey , HeaderKey as CryptoHeaderKey ,
42
+ scatter, HandshakeHeaderKey , HandshakeKey , HeaderKey as CryptoHeaderKey ,
42
43
HeaderProtectionMask , InitialHeaderKey , InitialKey , OneRttHeaderKey , OneRttKey , RetryKey ,
43
44
ZeroRttHeaderKey , ZeroRttKey ,
44
45
} ;
@@ -77,9 +78,9 @@ pub mod testing {
77
78
_packet_number : u64 ,
78
79
_header : & [ u8 ] ,
79
80
_payload : & mut [ u8 ] ,
80
- ) -> Result < ( ) , CryptoError > {
81
+ ) -> Result < ( ) , packet_protection :: Error > {
81
82
if self . fail_on_decrypt {
82
- return Err ( CryptoError :: DECRYPT_ERROR ) ;
83
+ return Err ( packet_protection :: Error :: DECRYPT_ERROR ) ;
83
84
}
84
85
85
86
Ok ( ( ) )
@@ -91,7 +92,7 @@ pub mod testing {
91
92
_packet_number : u64 ,
92
93
_header : & [ u8 ] ,
93
94
payload : & mut scatter:: Buffer ,
94
- ) -> Result < ( ) , CryptoError > {
95
+ ) -> Result < ( ) , packet_protection :: Error > {
95
96
// copy any bytes into the final slice
96
97
payload. flatten ( ) ;
97
98
Ok ( ( ) )
@@ -145,7 +146,7 @@ pub mod testing {
145
146
fn generate_tag ( _payload : & [ u8 ] ) -> IntegrityTag {
146
147
[ 0u8 ; INTEGRITY_TAG_LEN ]
147
148
}
148
- fn validate ( _payload : & [ u8 ] , _tag : IntegrityTag ) -> Result < ( ) , CryptoError > {
149
+ fn validate ( _payload : & [ u8 ] , _tag : IntegrityTag ) -> Result < ( ) , packet_protection :: Error > {
149
150
Ok ( ( ) )
150
151
}
151
152
}
0 commit comments