rsa

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Algorithm = "RSASSA-PKCS1-V1_5"

Algorithm defines the type for the RSA PKCS #1 v1.5 signature algorithm.

View Source
const MediaType = "application/vnd.ocm.signature.rsa"

MediaType defines the media type for a plain RSA signature.

View Source
const MediaTypePEM = signutils.MediaTypePEM

MediaTypePEM is used if the signature contains the public key certificate chain.

Variables

Functions

func CreateKeyPair

func CreateKeyPair() (priv signutils.GenericPrivateKey, pub signutils.GenericPublicKey, err error)

func GetPrivateKey

func GetPrivateKey(key interface{}) (*rsa.PrivateKey, error)

func GetPublicKey

func GetPublicKey(key interface{}) (*rsa.PublicKey, *pkix.Name, error)

func KeyData

func KeyData(key interface{}) ([]byte, error)

func NewHandler

func NewHandler() signing.SignatureHandler

func NewHandlerFor

func NewHandlerFor(m *Method) signing.SignatureHandler

func ParseKey

func ParseKey(data []byte) (interface{}, error)

func ParsePrivateKey

func ParsePrivateKey(data []byte) (*rsa.PrivateKey, error)

func ParsePublicKey

func ParsePublicKey(data []byte) (interface{}, error)

func PemBlockForKey

func PemBlockForKey(priv interface{}, gen ...bool) (*pem.Block, error)

func WriteKeyData

func WriteKeyData(key interface{}, w io.Writer) error

Types

type Handler

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

Handler is a signatures.Signer compatible struct to sign with RSASSA-PKCS1-V1_5. and a signatures.Verifier compatible struct to verify RSASSA-PKCS1-V1_5 signatures.

func (*Handler) Algorithm

func (h *Handler) Algorithm() string

func (Handler) CreateKeyPair

func (_ Handler) CreateKeyPair() (priv signutils.GenericPrivateKey, pub signutils.GenericPublicKey, err error)

func (*Handler) Sign

func (h *Handler) Sign(cctx credentials.Context, digest string, sctx signing.SigningContext) (signature *signing.Signature, err error)

func (*Handler) Verify

func (h *Handler) Verify(digest string, signature *signing.Signature, sctx signing.SigningContext) (err error)

Verify checks the signature, returns an error on verification failure.

type Method

type Method struct {
	Algorithm string
	MediaType string
	Sign      func(random io.Reader, priv *PrivateKey, hash crypto.Hash, hashed []byte) ([]byte, error)
	Verify    func(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) error
}

type PrivateKey

type PrivateKey = rsa.PrivateKey

func CreateRootCertificate

func CreateRootCertificate(sub *pkix.Name, validity time.Duration) (*x509.Certificate, *PrivateKey, error)

func CreateSigningCertificate

func CreateSigningCertificate(sub *pkix.Name, intermediate signutils.GenericCertificateChain, roots signutils.GenericCertificatePool, capriv signutils.GenericPrivateKey, validity time.Duration, isCA ...bool) (*x509.Certificate, []byte, *PrivateKey, error)

type PublicKey

type PublicKey = rsa.PublicKey

Jump to

Keyboard shortcuts

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