util

package
v0.0.0-...-b041ac7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package util provides helper data types and functions for the GREP11 examples

Index

Constants

This section is empty.

Variables

View Source
var (
	// The following variables are standardized elliptic curve definitions
	OIDNamedCurveP224      = asn1.ObjectIdentifier{1, 3, 132, 0, 33}
	OIDNamedCurveP256      = asn1.ObjectIdentifier{1, 2, 840, 10045, 3, 1, 7}
	OIDNamedCurveP384      = asn1.ObjectIdentifier{1, 3, 132, 0, 34}
	OIDNamedCurveP521      = asn1.ObjectIdentifier{1, 3, 132, 0, 35}
	OIDECPublicKey         = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1}
	OIDRSAPublicKey        = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1}
	OIDDHPublicKey         = asn1.ObjectIdentifier{1, 2, 840, 10046, 2}
	OIDNamedCurveSecp256k1 = asn1.ObjectIdentifier{1, 3, 132, 0, 10}
	OIDNamedCurveED25519   = asn1.ObjectIdentifier{1, 3, 101, 112}

	// Supported Dilithium strengths
	OIDDilithiumHigh = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 2, 267, 1, 6, 5} // Round 2 strength
)

Functions

func AttributeMap

func AttributeMap(attrs ep11.EP11Attributes) map[ep11.Attribute]*pb.AttributeValue

AttributeMap is a map conversion helper function

func AttributeValue

func AttributeValue(v interface{}) *pb.AttributeValue

AttributeValue converts a standard Golang type into an AttributeValue structure

func Convert

func Convert(err error) (bool, *pb.Grep11Error)

Convert is a helper function for generating proper Grep11Error structures

func DumpAttributes

func DumpAttributes(attrs map[ep11.Attribute][]byte) string

DumpAttributes converts an Attribute slice into a string of Attributes

func GetAttributeByteValue

func GetAttributeByteValue(val interface{}) ([]byte, error)

GetAttributeByteValue obtains the byte slice equivalent of an attribute struct

func GetNamedCurveFromOID

func GetNamedCurveFromOID(oid asn1.ObjectIdentifier) elliptic.Curve

GetNamedCurveFromOID returns an elliptic curve from the specified curve OID

func GetPubKey

func GetPubKey(spki []byte) (crypto.PublicKey, asn1.ObjectIdentifier, error)

GetPubKey converts an ep11 SPKI structure to a golang ecdsa.PublicKey

func GetPubkeyBytesFromSPKI

func GetPubkeyBytesFromSPKI(spki []byte) ([]byte, error)

GetPubkeyBytesFromSPKI extracts a coordinate bit array from the public key in SPKI format

func GetSignMechanismFromOID

func GetSignMechanismFromOID(oid asn1.ObjectIdentifier) (ep11.Mechanism, error)

GetSignMechanismFromOID returns the signing mechanism associated with an object identifier

func Pause

func Pause(m chan string, sigs chan os.Signal, message string)

Pause is a helper function that pauses test execution until the user types CTRL-c

func SetMechParm

func SetMechParm(parm []byte) *pb.Mechanism_ParameterB

SetMechParm is a helper function that returns a properly formatted mechanism parameter for byte slice parameters

Types

type DH2Int

type DH2Int struct {
	Prime *big.Int
	Base  *big.Int
}

DH2Int defines the Diffie-Hellman Prime and Base values extracted from the public key

type DHParam

type DHParam struct {
	Algorithm asn1.ObjectIdentifier
	PB        DH2Int
}

DHParam defines the Diffie-Hellman algorithm Identifier structure

type DHPubKeyASN

type DHPubKeyASN struct {
	Parameter DHParam
	PublicKey asn1.BitString
}

DHPubKeyASN defines the Diffie-Hellman public key ASN1 encoding structure for GREP11

type EP11PrivateKey

type EP11PrivateKey struct {
	// contains filtered or unexported fields
}

EP11PrivateKey MUST implement crypto.Signer interface so that the crypt/tls package can use an EP11PrivateKey in tls.Certificate: https://golang.org/pkg/crypto/tls/#Certificate

func NewEP11Signer

func NewEP11Signer(cryptoClient pb.CryptoClient, privKeyBlob []byte, spki []byte) (*EP11PrivateKey, error)

NewEP11Signer is used in the creation of a TLS certificate

func (*EP11PrivateKey) Public

func (priv *EP11PrivateKey) Public() crypto.PublicKey

Public is part of the crypto.Signer interface implementation

func (*EP11PrivateKey) Sign

func (priv *EP11PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

Sign returns a signature in ASN1 format Reference code crypto/ecdsa.go, func (priv *PrivateKey) Sign() ([]byte, error)

type IAMPerRPCCredentials

type IAMPerRPCCredentials struct {
	AccessToken string // Required if APIKey nor Endpoint are specified - IBM Cloud IAM access token
	APIKey      string // Required if AccessToken is not specified - IBM Cloud API key
	Endpoint    string // Required if AccessToken is not specified - IBM Cloud IAM endpoint
	// contains filtered or unexported fields
}

IAMPerRPCCredentials type defines the fields required for IBM Cloud IAM authentication This type implements the GRPC PerRPCCredentials interface

func (*IAMPerRPCCredentials) GetRequestMetadata

func (cr *IAMPerRPCCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata is used by GRPC for authentication

func (*IAMPerRPCCredentials) RequireTransportSecurity

func (cr *IAMPerRPCCredentials) RequireTransportSecurity() bool

RequireTransportSecurity is used by GRPC for authentication

Jump to

Keyboard shortcuts

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