EdgexAgent/device-gps-go/vendor/github.com/parallaxsecond/parsec-client-go/parsec/default_attributes.go
2025-07-10 20:30:06 +08:00

41 lines
1023 B
Go

// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
package parsec
import "github.com/parallaxsecond/parsec-client-go/parsec/algorithm"
type DefaultKeyAttributeFactory interface {
SigningKey() *KeyAttributes
}
type defaultKeyAttributeFactory struct{}
func DefaultKeyAttribute() DefaultKeyAttributeFactory {
return &defaultKeyAttributeFactory{}
}
func (f *defaultKeyAttributeFactory) SigningKey() *KeyAttributes {
const keyBits = 2048
const hashAlg = algorithm.HashAlgorithmTypeSHA256
return &KeyAttributes{
KeyBits: keyBits,
KeyType: NewKeyType().RsaKeyPair(),
KeyPolicy: &KeyPolicy{
KeyAlgorithm: algorithm.NewAsymmetricSignature().RsaPkcs1V15Sign(hashAlg),
KeyUsageFlags: &UsageFlags{
Cache: false,
Copy: false,
Decrypt: false,
Derive: false,
Encrypt: false,
Export: false,
SignHash: true,
SignMessage: true,
VerifyHash: true,
VerifyMessage: true,
},
},
}
}