mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-05 22:27:37 +03:00
Update go-hpke-compact
This commit is contained in:
parent
45d3afc8f9
commit
72a354caf9
6 changed files with 30 additions and 8 deletions
6
vendor/github.com/jedisct1/go-hpke-compact/README.md
generated
vendored
6
vendor/github.com/jedisct1/go-hpke-compact/README.md
generated
vendored
|
@ -126,4 +126,10 @@ secret1, err := clientCtx.Export("description 1")
|
|||
secret2, err := serverCtx.Export("description 2");
|
||||
```
|
||||
|
||||
### Access the raw cipher interface
|
||||
|
||||
```go
|
||||
cipher, err := suite.NewRawCipher(key)
|
||||
```
|
||||
|
||||
## That's it!
|
2
vendor/github.com/jedisct1/go-hpke-compact/go.mod
generated
vendored
2
vendor/github.com/jedisct1/go-hpke-compact/go.mod
generated
vendored
|
@ -4,5 +4,5 @@ go 1.16
|
|||
|
||||
require (
|
||||
github.com/powerman/check v1.3.1
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
|
||||
)
|
||||
|
|
22
vendor/github.com/jedisct1/go-hpke-compact/hpke.go
generated
vendored
22
vendor/github.com/jedisct1/go-hpke-compact/hpke.go
generated
vendored
|
@ -508,6 +508,22 @@ func (suite *Suite) NewAuthenticatedServerContext(clientPk []byte, enc []byte, s
|
|||
return ServerContext{inner: context}, nil
|
||||
}
|
||||
|
||||
// NewRawCipher - Access the raw cipher interface
|
||||
func (suite *Suite) NewRawCipher(key []byte) (cipher.AEAD, error) {
|
||||
switch suite.AeadID {
|
||||
case AeadAes128Gcm, AeadAes256Gcm:
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cipher.NewGCM(block)
|
||||
case AeadChaCha20Poly1305:
|
||||
return chacha20poly1305.New(key)
|
||||
default:
|
||||
return nil, errors.New("externally defined cipher")
|
||||
}
|
||||
}
|
||||
|
||||
func (state *aeadState) incrementCounter() error {
|
||||
carry := uint16(1)
|
||||
for i := len(state.counter); ; {
|
||||
|
@ -624,11 +640,11 @@ type aeadAesImpl struct {
|
|||
func newAesAead(key []byte) (aeadAesImpl, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return aeadAesImpl{}, nil
|
||||
return aeadAesImpl{}, err
|
||||
}
|
||||
aesGcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return aeadAesImpl{}, nil
|
||||
return aeadAesImpl{}, err
|
||||
}
|
||||
aead := aeadAesImpl{impl: aesGcm}
|
||||
return aead, nil
|
||||
|
@ -645,7 +661,7 @@ type aeadChaChaPolyImpl struct {
|
|||
func newChaChaPolyAead(key []byte) (aeadChaChaPolyImpl, error) {
|
||||
impl, err := chacha20poly1305.New(key)
|
||||
if err != nil {
|
||||
return aeadChaChaPolyImpl{}, nil
|
||||
return aeadChaChaPolyImpl{}, err
|
||||
}
|
||||
aead := aeadChaChaPolyImpl{impl: impl}
|
||||
return aead, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue