github.com/hyperledger/aries-framework-go@v0.3.2/pkg/secretlock/local/masterlock/pbkdf2/pbkdf2.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 // Package pbkdf2 provides an pbkdf2 implementation of secretlock as a masterlock. 8 // the underlying golang.org/x/crypto/pbkdf2 package implements IETF RFC 8018's PBKDF2 specification found at: 9 // https://tools.ietf.org/html/rfc8018#section-5.2. Similarly the NIST document 800-132 section 5 provides PBKDF 10 // recommendations. 11 package pbkdf2 12 13 import ( 14 "hash" 15 16 "github.com/hyperledger/aries-framework-go/component/kmscrypto/secretlock/local/masterlock/pbkdf2" 17 18 "github.com/hyperledger/aries-framework-go/pkg/secretlock" 19 ) 20 21 // NewMasterLock is responsible for encrypting/decrypting with a master key expanded from a passphrase using PBKDF2 22 // using `passphrase`, hash function `h`, `salt`. 23 // The salt is optional and can be set to nil. 24 // This implementation must not be used directly in Aries framework. It should be passed in 25 // as the second argument to local secret lock service constructor: 26 // `local.NewService(masterKeyReader io.Reader, secLock secretlock.Service)`. 27 func NewMasterLock(passphrase string, h func() hash.Hash, iterations int, salt []byte) (secretlock.Service, error) { 28 return pbkdf2.NewMasterLock(passphrase, h, iterations, salt) 29 }