common

package
v0.0.0-...-7d2fa90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 GetPublicKeyID(keyBytes []byte) *[32]byte

func NewPemEncodedPrivateKey

func NewPemEncodedPrivateKey() (*[]byte, error)

func NewPrivateKey

func NewPrivateKey() (*rsa.PrivateKey, error)

func NewRandomString

func NewRandomString(length int) string

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 TimeIt

func TimeIt(logger *zap.Logger, startTime time.Time, functionName string)

func ToInt32

func ToInt32(i int) (int32, error)

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL