@@ -15,39 +15,39 @@ fn test_stream_cipher_rabbit(
15
15
let mut rabbit_cipher1 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( key) ) ;
16
16
rabbit_cipher1. apply_keystream ( & mut data) ;
17
17
18
- let const1: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-crytographic -value]
18
+ let const1: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
19
19
let mut rabbit_cipher2 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( const1) ) ; // $ Sink
20
20
rabbit_cipher2. apply_keystream ( & mut data) ;
21
21
22
22
let mut rabbit_cipher3 = Rabbit :: new ( rabbit:: Key :: from_slice ( key) , rabbit:: Iv :: from_slice ( iv) ) ;
23
23
rabbit_cipher3. apply_keystream ( & mut data) ;
24
24
25
- let const4: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-crytographic -value]
25
+ let const4: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
26
26
let mut rabbit_cipher4 = Rabbit :: new ( rabbit:: Key :: from_slice ( const4) , rabbit:: Iv :: from_slice ( iv) ) ; // $ Sink
27
27
rabbit_cipher4. apply_keystream ( & mut data) ;
28
28
29
- let const5: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-crytographic -value]
29
+ let const5: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
30
30
let mut rabbit_cipher5 = Rabbit :: new ( rabbit:: Key :: from_slice ( key) , rabbit:: Iv :: from_slice ( const5) ) ; // $ Sink
31
31
rabbit_cipher5. apply_keystream ( & mut data) ;
32
32
33
33
// various expressions of constant arrays
34
34
35
35
let const6: & [ u8 ; 16 ] = & [ 0u8 ; 16 ] ; // (unused, so good)
36
36
37
- let const7: [ u8 ; 16 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-crytographic -value]
37
+ let const7: [ u8 ; 16 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
38
38
let mut rabbit_cipher7 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( & const7) ) ; // $ Sink
39
39
rabbit_cipher7. apply_keystream ( & mut data) ;
40
40
41
- let const8: & [ u8 ; 16 ] = & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-crytographic -value]
41
+ let const8: & [ u8 ; 16 ] = & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
42
42
let mut rabbit_cipher8 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( const8) ) ; // $ Sink
43
43
rabbit_cipher8. apply_keystream ( & mut data) ;
44
44
45
- let const9: [ u16 ; 8 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-crytographic -value]
45
+ let const9: [ u16 ; 8 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
46
46
let const9_conv = unsafe { const9. align_to :: < u8 > ( ) . 1 } ; // convert [u16;8] -> [u8;8]
47
47
let mut rabbit_cipher9 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( const9_conv) ) ; // $ Sink
48
48
rabbit_cipher9. apply_keystream ( & mut data) ;
49
49
50
- let const10: [ u8 ; 16 ] = unsafe { std:: mem:: zeroed ( ) } ; // $ Alert[rust/hardcoded-crytographic -value]
50
+ let const10: [ u8 ; 16 ] = unsafe { std:: mem:: zeroed ( ) } ; // $ Alert[rust/hardcoded-cryptographic -value]
51
51
let mut rabbit_cipher10 = RabbitKeyOnly :: new ( rabbit:: Key :: from_slice ( & const10) ) ; // $ Sink
52
52
rabbit_cipher10. apply_keystream ( & mut data) ;
53
53
}
@@ -63,25 +63,25 @@ fn test_block_cipher_aes(
63
63
let aes_cipher1 = Aes256 :: new ( key256. into ( ) ) ;
64
64
aes_cipher1. encrypt_block ( block128. into ( ) ) ;
65
65
66
- let const2 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-crytographic -value]
66
+ let const2 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
67
67
let aes_cipher2 = Aes256 :: new ( const2. into ( ) ) ; // $ Sink
68
68
aes_cipher2. encrypt_block ( block128. into ( ) ) ;
69
69
70
70
let aes_cipher3 = Aes256 :: new_from_slice ( key256) . unwrap ( ) ;
71
71
aes_cipher3. encrypt_block ( block128. into ( ) ) ;
72
72
73
- let const2 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-crytographic -value]
73
+ let const2 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
74
74
let aes_cipher4 = Aes256 :: new_from_slice ( const2) . unwrap ( ) ; // $ Sink
75
75
aes_cipher4. encrypt_block ( block128. into ( ) ) ;
76
76
77
77
let aes_cipher5 = cfb_mode:: Encryptor :: < aes:: Aes256 > :: new ( key. into ( ) , iv. into ( ) ) ;
78
78
_ = aes_cipher5. encrypt_b2b ( input, output) . unwrap ( ) ;
79
79
80
- let const6 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-crytographic -value]
80
+ let const6 = & [ 0u8 ; 32 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
81
81
let aes_cipher6 = cfb_mode:: Encryptor :: < aes:: Aes256 > :: new ( const6. into ( ) , iv. into ( ) ) ; // $ Sink
82
82
_ = aes_cipher6. encrypt_b2b ( input, output) . unwrap ( ) ;
83
83
84
- let const7 = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-crytographic -value]
84
+ let const7 = & [ 0u8 ; 16 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
85
85
let aes_cipher7 = cfb_mode:: Encryptor :: < aes:: Aes256 > :: new ( key. into ( ) , const7. into ( ) ) ; // $ Sink
86
86
_ = aes_cipher7. encrypt_b2b ( input, output) . unwrap ( ) ;
87
87
@@ -91,18 +91,18 @@ fn test_block_cipher_aes(
91
91
let aes_cipher8 = cfb_mode:: Encryptor :: < aes:: Aes256 > :: new ( key8. into ( ) , iv. into ( ) ) ;
92
92
_ = aes_cipher8. encrypt_b2b ( input, output) . unwrap ( ) ;
93
93
94
- let key9: & [ u8 ] = "1234567890123456" . as_bytes ( ) ; // $ MISSING: Alert[rust/hardcoded-crytographic -value]
94
+ let key9: & [ u8 ] = "1234567890123456" . as_bytes ( ) ; // $ MISSING: Alert[rust/hardcoded-cryptographic -value]
95
95
let aes_cipher9 = cfb_mode:: Encryptor :: < aes:: Aes256 > :: new ( key9. into ( ) , iv. into ( ) ) ;
96
96
_ = aes_cipher9. encrypt_b2b ( input, output) . unwrap ( ) ;
97
97
98
98
let key10: [ u8 ; 32 ] = match base64:: engine:: general_purpose:: STANDARD . decode ( key_str) {
99
99
Ok ( x) => x. try_into ( ) . unwrap ( ) ,
100
- Err ( _) => "1234567890123456" . as_bytes ( ) . try_into ( ) . unwrap ( ) // $ MISSING: Alert[rust/hardcoded-crytographic -value]
100
+ Err ( _) => "1234567890123456" . as_bytes ( ) . try_into ( ) . unwrap ( ) // $ MISSING: Alert[rust/hardcoded-cryptographic -value]
101
101
} ;
102
102
let aes_cipher10 = Aes256 :: new ( & key10. into ( ) ) ;
103
103
aes_cipher10. encrypt_block ( block128. into ( ) ) ;
104
104
105
- if let Ok ( const11) = base64:: engine:: general_purpose:: STANDARD . decode ( "1234567890123456" ) { // $ MISSING: Alert[rust/hardcoded-crytographic -value]
105
+ if let Ok ( const11) = base64:: engine:: general_purpose:: STANDARD . decode ( "1234567890123456" ) { // $ MISSING: Alert[rust/hardcoded-cryptographic -value]
106
106
let key11: [ u8 ; 32 ] = const11. try_into ( ) . unwrap ( ) ;
107
107
let aes_cipher11 = Aes256 :: new ( & key11. into ( ) ) ;
108
108
aes_cipher11. encrypt_block ( block128. into ( ) ) ;
@@ -121,14 +121,14 @@ fn test_aes_gcm(
121
121
let cipher1 = Aes256Gcm :: new ( & key1) ;
122
122
let _ = cipher1. encrypt ( & nonce1, b"plaintext" . as_ref ( ) ) . unwrap ( ) ;
123
123
124
- let key2: [ u8 ; 32 ] = [ 0 ; 32 ] ; // $ Alert[rust/hardcoded-crytographic -value]
125
- let nonce2 = [ 0 ; 12 ] ; // $ Alert[rust/hardcoded-crytographic -value]
124
+ let key2: [ u8 ; 32 ] = [ 0 ; 32 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
125
+ let nonce2 = [ 0 ; 12 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
126
126
let cipher2 = Aes256Gcm :: new ( & key2. into ( ) ) ; // $ Sink
127
127
let _ = cipher2. encrypt ( & nonce2. into ( ) , b"plaintext" . as_ref ( ) ) . unwrap ( ) ; // $ Sink
128
128
129
- let key3_array: & [ u8 ; 32 ] = & [ 0xff ; 32 ] ; // $ Alert[rust/hardcoded-crytographic -value]
129
+ let key3_array: & [ u8 ; 32 ] = & [ 0xff ; 32 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
130
130
let key3 = Key :: < Aes256Gcm > :: from_slice ( key3_array) ;
131
- let nonce3: [ u8 ; 12 ] = [ 0xff ; 12 ] ; // $ Alert[rust/hardcoded-crytographic -value]
131
+ let nonce3: [ u8 ; 12 ] = [ 0xff ; 12 ] ; // $ Alert[rust/hardcoded-cryptographic -value]
132
132
let cipher3 = Aes256Gcm :: new ( & key3) ; // $ Sink
133
133
let _ = cipher3. encrypt ( & nonce3. into ( ) , b"plaintext" . as_ref ( ) ) . unwrap ( ) ; // $ Sink
134
134
}
0 commit comments