rsakys

package
v0.0.0-...-799adc7 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: Unlicense Imports: 8 Imported by: 2

Documentation

Overview

Package rsakys is an abstraction layer for the crypto/rsa and connected packages.

The purpose is to avoid a lot of boilerplate code and error checks when creating, writing, reading, or transforming RSA based keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePKCS1Keypair

func GeneratePKCS1Keypair(path, keyname string, bitSize int) (*rsa.PrivateKey, error)

GeneratePKCS1Keypair generates a new private key of the given bit size, writes its private key part with '.pem' suffix as PKCS1 PEM file to disc, writes its public key part with '.pub' suffix as PKIX PEM file to disc, and returns the RSA private key struct

func GeneratePKCS1PrivateKey

func GeneratePKCS1PrivateKey(path string, bitSize int) (*rsa.PrivateKey, error)

GeneratePKCS1PrivateKey generates a new private key of the given bit size, writes it as PKCS1 PEM file to disc, and returns the RSA private key struct

func GeneratePKCS8Keypair

func GeneratePKCS8Keypair(path, keyname string, bitSize int) (*rsa.PrivateKey, error)

GeneratePKCS8Keypair generates a new private key of the given bit size, writes its private key part with '.pem' suffix as PKCS8 PEM file to disc, writes its public key part with '.pub' suffix as PKIX PEM file to disc, and returns the RSA private key struct

func GeneratePKCS8PrivateKey

func GeneratePKCS8PrivateKey(path string, bitSize int) (*rsa.PrivateKey, error)

GeneratePKCS8PrivateKey generates a new private key of the given bit size, writes it as PKCS8 PEM file to disc, and returns the RSA private key struct

func GetPKCS1PrivateKey

func GetPKCS1PrivateKey(bitSize int) ([]byte, error)

GetPKCS1PrivateKey generates an RSA private key and returns the PKCS1 byterepresentation of the PEM block

func GetPKCS1PrivateKeyString

func GetPKCS1PrivateKeyString(privateKey *rsa.PrivateKey) ([]byte, error)

GetPKCS1PrivateKeyString returns the PKCS1 byterepresentation of a given RSA private key struct

func GetPKCS1PublicKeyString

func GetPKCS1PublicKeyString(publicKey *rsa.PublicKey) ([]byte, error)

GetPKCS1PublicKeyString returns the PKCS1 byterepresentation of a given RSA public key struct

func GetPKCS8PrivateKey

func GetPKCS8PrivateKey(bitSize int) ([]byte, error)

GetPKCS8PrivateKey generates an RSA private key and returns the PKCS8 byterepresentation of the PEM block

func GetPKCS8PrivateKeyString

func GetPKCS8PrivateKeyString(privateKey *rsa.PrivateKey) ([]byte, error)

GetPKCS8PrivateKeyString returns the PKCS8 byterepresentation of a given RSA private key struct

func GetPKIXPublicKeyString

func GetPKIXPublicKeyString(publicKey *rsa.PublicKey) ([]byte, error)

GetPKIXPublicKeyString returns the PKIX byterepresentation of a given RSA public key struct

func GetPrivateKey

func GetPrivateKey(bitSize int) (*rsa.PrivateKey, error)

GetPrivateKey generates an RSA private key struct of the given bit size

func ReadPrivate

func ReadPrivate(path string) (*rsa.PrivateKey, error)

ReadPrivate reads a private key PEM file and returns the private key struct

func ReadPrivatePKCS1

func ReadPrivatePKCS1(path string) ([]byte, error)

ReadPrivatePKCS1 reads a private key PEM file and returns a PKCS1 encoded private key byte slice

func ReadPrivatePKCS8

func ReadPrivatePKCS8(path string) ([]byte, error)

ReadPrivatePKCS8 reads a private key PEM file and returns a PKCS8 encoded private key byte slice

func ReadPublic

func ReadPublic(path string) (*rsa.PublicKey, error)

ReadPublic reads a public key PEM file and returns the public key struct

func ReadPublicPKCS1

func ReadPublicPKCS1(path string) ([]byte, error)

ReadPublicPKCS1 reads a public key PEM file and returns a PKCS1 encoded public key byte slice

func ReadPublicPKIX

func ReadPublicPKIX(path string) ([]byte, error)

ReadPublicPKIX reads a public key PEM file and returns a PKIX encoded public key byte slice

func WritePKCS1PrivateKey

func WritePKCS1PrivateKey(privateKey *rsa.PrivateKey, path string) error

WritePKCS1PrivateKey writes a given RSA private key as PKCS1 PEM block to disc

func WritePKCS1PublicKey

func WritePKCS1PublicKey(publicKey *rsa.PublicKey, path string) error

WritePKCS1PublicKey writes the public key part of a given RSA private key as PKCS1 PEM block to disc

func WritePKCS8PrivateKey

func WritePKCS8PrivateKey(privateKey *rsa.PrivateKey, path string) error

WritePKCS8PrivateKey writes a given RSA private key as PKCS8 PEM block to disc

func WritePKIXPublicKey

func WritePKIXPublicKey(publicKey *rsa.PublicKey, path string) error

WritePKIXPublicKey writes the public key part of a given RSA private key as PKIX PEM block to disc

Types

This section is empty.

Jump to

Keyboard shortcuts

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