feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
26
vendor/github.com/ProtonMail/go-crypto/openpgp/s2k/s2k_cache.go
generated
vendored
Normal file
26
vendor/github.com/ProtonMail/go-crypto/openpgp/s2k/s2k_cache.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package s2k
|
||||
|
||||
// Cache stores keys derived with s2k functions from one passphrase
|
||||
// to avoid recomputation if multiple items are encrypted with
|
||||
// the same parameters.
|
||||
type Cache map[Params][]byte
|
||||
|
||||
// GetOrComputeDerivedKey tries to retrieve the key
|
||||
// for the given s2k parameters from the cache.
|
||||
// If there is no hit, it derives the key with the s2k function from the passphrase,
|
||||
// updates the cache, and returns the key.
|
||||
func (c *Cache) GetOrComputeDerivedKey(passphrase []byte, params *Params, expectedKeySize int) ([]byte, error) {
|
||||
key, found := (*c)[*params]
|
||||
if !found || len(key) != expectedKeySize {
|
||||
var err error
|
||||
derivedKey := make([]byte, expectedKeySize)
|
||||
s2k, err := params.Function()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s2k(derivedKey, passphrase)
|
||||
(*c)[*params] = key
|
||||
return derivedKey, nil
|
||||
}
|
||||
return key, nil
|
||||
}
|
||||
Reference in New Issue
Block a user