File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ var streamList = map[string]struct {
50
50
"AES-192-CFB" : {24 , shadowstream .AESCFB },
51
51
"AES-256-CFB" : {32 , shadowstream .AESCFB },
52
52
"CHACHA20-IETF" : {32 , shadowstream .Chacha20IETF },
53
+ "XCHACHA20" : {32 , shadowstream .Xchacha20 },
53
54
}
54
55
55
56
// ListCipher returns a list of available cipher names sorted alphabetically.
Original file line number Diff line number Diff line change @@ -70,3 +70,22 @@ func Chacha20IETF(key []byte) (Cipher, error) {
70
70
}
71
71
return chacha20ietfkey (key ), nil
72
72
}
73
+
74
+ type xchacha20key []byte
75
+
76
+ func (k xchacha20key ) IVSize () int { return chacha20 .XNonceSize }
77
+ func (k xchacha20key ) Decrypter (iv []byte ) cipher.Stream { return k .Encrypter (iv ) }
78
+ func (k xchacha20key ) Encrypter (iv []byte ) cipher.Stream {
79
+ ciph , err := chacha20 .NewCipher (k , iv )
80
+ if err != nil {
81
+ panic (err ) // should never happen
82
+ }
83
+ return ciph
84
+ }
85
+
86
+ func Xchacha20 (key []byte ) (Cipher , error ) {
87
+ if len (key ) != chacha20 .KeySize {
88
+ return nil , KeySizeError (chacha20 .KeySize )
89
+ }
90
+ return xchacha20key (key ), nil
91
+ }
You can’t perform that action at this time.
0 commit comments