diff options
author | Wim <wim@42.be> | 2022-01-31 00:27:37 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2022-03-20 14:57:48 +0100 |
commit | e3cafeaf9292f67459ff1d186f68283bfaedf2ae (patch) | |
tree | b69c39620aa91dba695b3b935c6651c0fb37ce75 /vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go | |
parent | e7b193788a56ee7cdb02a87a9db0ad6724ef66d5 (diff) | |
download | matterbridge-msglm-e3cafeaf9292f67459ff1d186f68283bfaedf2ae.tar.gz matterbridge-msglm-e3cafeaf9292f67459ff1d186f68283bfaedf2ae.tar.bz2 matterbridge-msglm-e3cafeaf9292f67459ff1d186f68283bfaedf2ae.zip |
Add dependencies/vendor (whatsapp)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go b/vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go deleted file mode 100644 index 3d7361f0..00000000 --- a/vendor/github.com/Rhymen/go-whatsapp/crypto/hkdf/hkdf.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -HKDF is a simple key derivation function (KDF) based on -a hash-based message authentication code (HMAC). It was initially proposed by its authors as a building block in -various protocols and applications, as well as to discourage the proliferation of multiple KDF mechanisms. -The main approach HKDF follows is the "extract-then-expand" paradigm, where the KDF logically consists of two modules: -the first stage takes the input keying material and "extracts" from it a fixed-length pseudorandom key, and then the -second stage "expands" this key into several additional pseudorandom keys (the output of the KDF). -*/ -package hkdf - -import ( - "crypto/sha256" - "fmt" - "golang.org/x/crypto/hkdf" - "io" -) - -/* -Expand expands a given key with the HKDF algorithm. -*/ -func Expand(key []byte, length int, info string) ([]byte, error) { - var h io.Reader - if info == "" { - /* - Only used during initial login - Pseudorandom Key is provided by server and has not to be created - */ - h = hkdf.Expand(sha256.New, key, []byte(info)) - } else { - /* - Used every other time - Pseudorandom Key is created during kdf.New - This is the normal that crypto/hkdf is used - */ - h = hkdf.New(sha256.New, key, nil, []byte(info)) - } - out := make([]byte, length) - n, err := io.ReadAtLeast(h, out, length) - if err != nil { - return nil, err - } - if n != length { - return nil, fmt.Errorf("new key to short") - } - - return out, nil -} |