本文整理汇总了Golang中github.com/docker/notary/trustmanager.KeyStore类的典型用法代码示例。如果您正苦于以下问题:Golang KeyStore类的具体用法?Golang KeyStore怎么用?Golang KeyStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyStore类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: testAddKey
func testAddKey(t *testing.T, store trustmanager.KeyStore) (data.PrivateKey, error) {
privKey, err := trustmanager.GenerateECDSAKey(rand.Reader)
assert.NoError(t, err)
err = store.AddKey(privKey.ID(), data.CanonicalRootRole, privKey)
return privKey, err
}
开发者ID:runcom,项目名称:notary,代码行数:7,代码来源:yubikeystore_test.go
示例2: testAddKey
func testAddKey(t *testing.T, store trustmanager.KeyStore) (data.PrivateKey, error) {
privKey, err := utils.GenerateECDSAKey(rand.Reader)
require.NoError(t, err)
err = store.AddKey(trustmanager.KeyInfo{Role: data.CanonicalRootRole, Gun: ""}, privKey)
return privKey, err
}
开发者ID:jfrazelle,项目名称:notary,代码行数:7,代码来源:yubikeystore_test.go
示例3: moveKeys
func moveKeys(oldKeyStore, newKeyStore trustmanager.KeyStore) error {
for f := range oldKeyStore.ListKeys() {
privateKey, alias, err := oldKeyStore.GetKey(f)
if err != nil {
return err
}
err = newKeyStore.AddKey(f, alias, privateKey)
if err != nil {
return err
}
}
return nil
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:16,代码来源:import_export.go
示例4: moveKeys
func moveKeys(oldKeyStore, newKeyStore trustmanager.KeyStore) error {
for keyID, keyInfo := range oldKeyStore.ListKeys() {
privateKey, _, err := oldKeyStore.GetKey(keyID)
if err != nil {
return err
}
err = newKeyStore.AddKey(keyInfo, privateKey)
if err != nil {
return err
}
}
return nil
}
开发者ID:mbentley,项目名称:notary,代码行数:16,代码来源:import_export.go
示例5: moveKeysByGUN
func moveKeysByGUN(oldKeyStore, newKeyStore trustmanager.KeyStore, gun string) error {
for relKeyPath := range oldKeyStore.ListKeys() {
// Skip keys that aren't associated with this GUN
if !strings.HasPrefix(relKeyPath, filepath.FromSlash(gun)) {
continue
}
privKey, alias, err := oldKeyStore.GetKey(relKeyPath)
if err != nil {
return err
}
err = newKeyStore.AddKey(relKeyPath, alias, privKey)
if err != nil {
return err
}
}
return nil
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:20,代码来源:import_export.go
示例6: moveKeysByGUN
func moveKeysByGUN(oldKeyStore, newKeyStore trustmanager.KeyStore, gun string) error {
for keyID, keyInfo := range oldKeyStore.ListKeys() {
// Skip keys that aren't associated with this GUN
if keyInfo.Gun != gun {
continue
}
privKey, _, err := oldKeyStore.GetKey(keyID)
if err != nil {
return err
}
err = newKeyStore.AddKey(keyInfo, privKey)
if err != nil {
return err
}
}
return nil
}
开发者ID:mbentley,项目名称:notary,代码行数:20,代码来源:import_export.go
示例7: keyPassphraseChange
// keyPassphraseChange changes the passphrase for a private key based on ID
func (k *keyCommander) keyPassphraseChange(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
cmd.Usage()
return fmt.Errorf("must specify the key ID of the key to change the passphrase of")
}
config, err := k.configGetter()
if err != nil {
return err
}
ks, err := k.getKeyStores(config, true, false)
if err != nil {
return err
}
keyID := args[0]
// This is an invalid ID
if len(keyID) != notary.SHA256HexSize {
return fmt.Errorf("invalid key ID provided: %s", keyID)
}
// Find which keyStore we should replace the key password in, and replace if we find it
var foundKeyStore trustmanager.KeyStore
var privKey data.PrivateKey
var keyInfo trustmanager.KeyInfo
var cs *cryptoservice.CryptoService
for _, keyStore := range ks {
cs = cryptoservice.NewCryptoService(keyStore)
if privKey, _, err = cs.GetPrivateKey(keyID); err == nil {
foundKeyStore = keyStore
break
}
}
if foundKeyStore == nil {
return fmt.Errorf("could not retrieve local key for key ID provided: %s", keyID)
}
// Must use a different passphrase retriever to avoid caching the
// unlocking passphrase and reusing that.
passChangeRetriever := k.getRetriever()
var addingKeyStore trustmanager.KeyStore
switch foundKeyStore.Name() {
case "yubikey":
addingKeyStore, err = getYubiStore(nil, passChangeRetriever)
keyInfo = trustmanager.KeyInfo{Role: data.CanonicalRootRole}
default:
addingKeyStore, err = trustmanager.NewKeyFileStore(config.GetString("trust_dir"), passChangeRetriever)
if err != nil {
return err
}
keyInfo, err = foundKeyStore.GetKeyInfo(keyID)
}
if err != nil {
return err
}
err = addingKeyStore.AddKey(keyInfo, privKey)
if err != nil {
return err
}
cmd.Printf("\nSuccessfully updated passphrase for key ID: %s\n", keyID)
return nil
}
开发者ID:jfrazelle,项目名称:notary,代码行数:63,代码来源:keys.go
注:本文中的github.com/docker/notary/trustmanager.KeyStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论