Documentation
¶
Overview ¶
Package cryptoutils provides cryptographic utility functions.
Index ¶
- Constants
- func CryptCBC(blockCipher cipher.Block, iv []byte, data []byte, encrypt bool) []byte
- func CryptoHash(alg crypto.Hash, data []byte) []byte
- func CryptoHashByOid(oid asn1.ObjectIdentifier, data []byte) []byte
- func CryptoHashDigestSize(alg crypto.Hash) int
- func CryptoHashOidToAlg(oid asn1.ObjectIdentifier) crypto.Hash
- func DesKeyAdjustParity(key []byte) []byte
- func EllipticP192() elliptic.Curve
- func EncodeX962EcPoint(ec elliptic.Curve, point *EcPoint) []byte
- func GetCipherForKey(alg BlockCipherAlg, key []byte) (cipher.Block, error)
- func ISO9797Method2Pad(data []byte, blockSize int) []byte
- func ISO9797Method2Unpad(data []byte) []byte
- func ISO9797RetailMacDes(key []byte, data []byte) (mac []byte, err error)
- func KDF(k []byte, c KDFCounterType, alg BlockCipherAlg, keySizeBits int) []byte
- func RandomBytes(length int) []byte
- func RsaDecryptWithPublicKey(ciphertext []byte, publicKey RsaPublicKey) []byte
- type BlockCipherAlg
- type ECCurve
- type ECField
- type EcKeypair
- type EcPoint
- type KDFCounterType
- type KeyGeneratorEcFn
- type RandomBytesFn
- type RsaPublicKey
Constants ¶
View Source
const DES_BLOCK_SIZE_BYTES = 8
Variables ¶
This section is empty.
Functions ¶
func CryptoHashByOid ¶
func CryptoHashByOid(oid asn1.ObjectIdentifier, data []byte) []byte
hashes the data using the hash algorithm specified by oid panics if hash algorithm is not supported
func CryptoHashDigestSize ¶
func CryptoHashOidToAlg ¶
func CryptoHashOidToAlg(oid asn1.ObjectIdentifier) crypto.Hash
panics if hash algorithm is not supported
func DesKeyAdjustParity ¶
func EllipticP192 ¶
support for P192 (secp-192r1) which is required by some countries but not supported by the go libraries
func GetCipherForKey ¶
func GetCipherForKey(alg BlockCipherAlg, key []byte) (cipher.Block, error)
NB supports 8/16/24 byte key lengths for DES
func ISO9797Method2Pad ¶
func ISO9797Method2Unpad ¶
panics if data is not padded
func ISO9797RetailMacDes ¶
ISO-9797 Retail MAC (DES) key: 16 bytes (double) DES key error: if invalid key length (not 16 bytes) or data not aligned to block boundary (8 bytes)
func KDF ¶
func KDF(k []byte, c KDFCounterType, alg BlockCipherAlg, keySizeBits int) []byte
NB expects keySizeBits=112 for TDES
func RandomBytes ¶
func RsaDecryptWithPublicKey ¶
func RsaDecryptWithPublicKey(ciphertext []byte, publicKey RsaPublicKey) []byte
Types ¶
type EcKeypair ¶
func KeyGeneratorEc ¶
type KDFCounterType ¶
type KDFCounterType int
const ( KDF_COUNTER_KSENC KDFCounterType = 1 KDF_COUNTER_KSMAC KDFCounterType = 2 KDF_COUNTER_PACE KDFCounterType = 3 )
type KeyGeneratorEcFn ¶
type RandomBytesFn ¶
Click to show internal directories.
Click to hide internal directories.