Documentation
¶
Overview ¶
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
package github.com/HPInc/krypton-dsts/service/common Author: Mahesh Unnikrishnan Component: Krypton Device Security Token Service (C) HP Development Company, LP
Index ¶
- Variables
- func GetCertificateThumbprint(cert *x509.Certificate) string
- func GetPublicKeyID(keyBytes []byte) *[32]byte
- func NewPemEncodedPrivateKey() (*[]byte, error)
- func NewPrivateKey() (*rsa.PrivateKey, error)
- func NewRandomString(length int) string
- func ParseCertificate(certBytes []byte) (*x509.Certificate, error)
- func ParseRsaPrivateKey(pemKey string) (*rsa.PrivateKey, error)
- func TimeIt(logger *zap.Logger, startTime time.Time, functionName string)
- func ToInt32(i int) (int32, error)
- func VerifyCertificate(cert *x509.Certificate) error
- func VerifyDeviceIDInCertificateCommonName(cert *x509.Certificate, deviceID string) bool
- type ByteBuffer
- type JSONWebKey
Constants ¶
This section is empty.
Variables ¶
var ( ErrParseCertificate = errors.New("failed to parse certificate from DER bytes") ErrCertificateNotYetValid = errors.New("certificate is not yet valid") ErrCertificateExpired = errors.New("certificate has already expired") ErrInvalidCertificateSignatureAlgorithm = errors.New("certificate has unsupported signature algorithm") ErrInvalidPublicKeyAlgorithm = errors.New("certificate has unsupported public key algorithm") ErrInvalidKeyUsage = errors.New("certificate has invalid extended key usage") ErrInvalidExtKeyUsage = errors.New("certificate has invalid extended key usage") ErrPrivateKeyPemDecodeFailed = errors.New("failed to parse PEM encoded private key") ErrPrivateKeyCreationFailed = errors.New("failed to create private key") )
Functions ¶
func GetCertificateThumbprint ¶
func GetCertificateThumbprint(cert *x509.Certificate) string
Return a SHA256 checksum of the raw certificate as its thumbprint.
func GetPublicKeyID ¶
func NewPemEncodedPrivateKey ¶
func NewPrivateKey ¶
func NewPrivateKey() (*rsa.PrivateKey, error)
func NewRandomString ¶
func ParseCertificate ¶
func ParseCertificate(certBytes []byte) (*x509.Certificate, error)
Parse the certificate from the provided DER bytes.
func ParseRsaPrivateKey ¶
func ParseRsaPrivateKey(pemKey string) (*rsa.PrivateKey, error)
Parse the PEM encoded private key
func ToInt32 ¶
toInt32 converts int to int32 in a safe way. You get error when the value is out of the 32-bit range.
func VerifyCertificate ¶
func VerifyCertificate(cert *x509.Certificate) error
VerifyCertificate - perform some verification checks on the certificate.
func VerifyDeviceIDInCertificateCommonName ¶
func VerifyDeviceIDInCertificateCommonName(cert *x509.Certificate, deviceID string) bool
VerifyDeviceIDInCertificateCommonName - check if the device ID in the certificate's common name field matches the specified device ID.
Types ¶
type ByteBuffer ¶
type ByteBuffer struct {
Data []byte
}
func NewBufferFromInt ¶
func NewBufferFromInt(num uint64) *ByteBuffer
type JSONWebKey ¶
type JSONWebKey struct { KeyType string `json:"kty,omitempty"` Use string `json:"use,omitempty"` KeyID string `json:"kid,omitempty"` Alg string `json:"alg,omitempty"` X5t string `json:"x5t,omitempty"` K *ByteBuffer `json:"k,omitempty"` X *ByteBuffer `json:"x,omitempty"` Y *ByteBuffer `json:"y,omitempty"` N string `json:"n,omitempty"` E string `json:"e,omitempty"` X5c []string `json:"x5c,omitempty"` }