utils

package
v1.0.0-preview Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AESKeyLength is the default AES key length
	AESKeyLength = 32

	// NonceSize is the default NonceSize
	NonceSize = 24
)

Variables

View Source
var (
	// TCertEncTCertIndex oid for TCertIndex
	TCertEncTCertIndex = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 7}

	// TCertEncEnrollmentID is the ASN1 object identifier of the TCert index.
	TCertEncEnrollmentID = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 8}

	// TCertEncAttributesBase is the base ASN1 object identifier for attributes.
	// When generating an extension to include the attribute an index will be
	// appended to this Object Identifier.
	TCertEncAttributesBase = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6}

	// TCertAttributesHeaders is the ASN1 object identifier of attributes header.
	TCertAttributesHeaders = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 9}
)

Functions

func AEStoEncryptedPEM

func AEStoEncryptedPEM(raw []byte, pwd []byte) ([]byte, error)

AEStoEncryptedPEM encapsulates an AES key in the encrypted PEM format

func AEStoPEM

func AEStoPEM(raw []byte) []byte

AEStoPEM encapsulates an AES key in the PEM format

func CBCDecrypt

func CBCDecrypt(key, src []byte) ([]byte, error)

CBCDecrypt decrypts using CBC mode

func CBCEncrypt

func CBCEncrypt(key, s []byte) ([]byte, error)

CBCEncrypt encrypts using CBC mode

func CBCPKCS7Decrypt

func CBCPKCS7Decrypt(key, src []byte) ([]byte, error)

CBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding

func CBCPKCS7Encrypt

func CBCPKCS7Encrypt(key, src []byte) ([]byte, error)

CBCPKCS7Encrypt combines CBC encryption and PKCS7 padding

func DERToX509Certificate

func DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)

DERToX509Certificate converts der to x509

func ECDSASign

func ECDSASign(signKey interface{}, msg []byte) ([]byte, error)

ECDSASign signs

func GenAESKey

func GenAESKey() ([]byte, error)

GenAESKey returns a random AES key of length AESKeyLength

func GetCriticalExtension

func GetCriticalExtension(cert *x509.Certificate, oid asn1.ObjectIdentifier) ([]byte, error)

GetCriticalExtension returns a requested critical extension. It also remove it from the list of unhandled critical extensions

func IntArrayEquals

func IntArrayEquals(a []int, b []int) bool

IntArrayEquals checks if the arrays of ints are the same

func NewECDSAKey

func NewECDSAKey() (*ecdsa.PrivateKey, error)

NewECDSAKey generates a new ECDSA Key

func NewSelfSignedCert

func NewSelfSignedCert() ([]byte, interface{}, error)

NewSelfSignedCert create a self signed certificate

func PEMtoAES

func PEMtoAES(raw []byte, pwd []byte) ([]byte, error)

PEMtoAES extracts from the PEM an AES key

func PKCS7Padding

func PKCS7Padding(src []byte) []byte

PKCS7Padding pads as prescribed by the PKCS7 standard

func PKCS7UnPadding

func PKCS7UnPadding(src []byte) ([]byte, error)

PKCS7UnPadding unpads as prescribed by the PKCS7 standard

Types

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

ECDSASignature represents an ECDSA signature

Jump to

Keyboard shortcuts

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