Documentation ¶
Overview ¶
Package crypto provides funcs and types used by other packages to perform crypto related ops
Index ¶
- Variables
- func AddPKCSPadding(src []byte) []byte
- func AesCTRXOR(key, input, nonce []byte) ([]byte, error)
- func DeriveKeyFromPassword(password string, p KDParams) ([]byte, error)
- func GenerateKeyPair() (PrivateKey, PublicKey, error)
- func GetRandomBytes(n int) ([]byte, error)
- func GetRandomBytesToBuffer(n int, buff []byte) error
- func GetRandomUInt32(max uint32) uint32
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h types.Hash32)
- func MinInt(x, y int) int
- func MinInt32(x, y int32) int32
- func MinInt64(x, y int64) int64
- func NewUUID() [16]byte
- func Pkcs7Pad(in []byte) []byte
- func Pkcs7Unpad(in []byte) []byte
- func RemovePKCSPadding(src []byte) ([]byte, error)
- func Sha256(data ...[]byte) []byte
- func UUIDString() string
- type KDParams
- type Key
- type PrivateKey
- type PublicKey
- type UUID
Constants ¶
This section is empty.
Variables ¶
var DefaultCypherParams = KDParams{N: 262144, R: 8, P: 1, SaltLen: 16, DKLen: 32}
DefaultCypherParams used for key derivation by the app.
Functions ¶
func AddPKCSPadding ¶
AddPKCSPadding Adds padding to a block of data.
func AesCTRXOR ¶
AesCTRXOR is an AES cipher following https://leanpub.com/gocrypto/read#leanpub-auto-aes-cbc .
func DeriveKeyFromPassword ¶
DeriveKeyFromPassword derives a key from password using the provided KDParams params.
func GenerateKeyPair ¶
func GenerateKeyPair() (PrivateKey, PublicKey, error)
GenerateKeyPair generates a private and public key pair.
func GetRandomBytes ¶
GetRandomBytes returns n random bytes. It returns an error if the system's pgn fails.
func GetRandomBytesToBuffer ¶
GetRandomBytesToBuffer puts n random bytes using go crypto.rand into provided buff slice. buff: a slice allocated by called to hold n bytes.
func GetRandomUInt32 ¶
GetRandomUInt32 returns a uint32 in the range [0 - max).
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func Pkcs7Unpad ¶
Pkcs7Unpad returned in without padded data using pkcs7 padding spec.
func RemovePKCSPadding ¶
RemovePKCSPadding Removes padding from data that was added using AddPKCSPadding.
Types ¶
type KDParams ¶
type KDParams struct { N int `json:"n"` R int `json:"r"` P int `json:"p"` SaltLen int `json:"saltLen"` DKLen int `json:"dkLen"` Salt string `json:"salt"` // hex encoded }
KDParams defines key derivation scheme params.
type Key ¶
type Key interface { String() string // this is a base58 encoded of Bytes() Bytes() []byte // raw key binary data Pretty() string // pretty print key id }
Key defines basic key caps.
type PrivateKey ¶
type PrivateKey interface { Key GetPublicKey() PublicKey // get the pub key corresponding to this priv key Sign([]byte) []byte // Decrypt binary data encrypted with the public key of this private key Decrypt(in []byte) ([]byte, error) InternalKey() *btcec.PrivateKey }
PrivateKey defines a private encryption key.
func NewPrivateKey ¶
func NewPrivateKey(data []byte) (PrivateKey, error)
NewPrivateKey creates a new private key from data.
func NewPrivateKeyFromString ¶
func NewPrivateKeyFromString(s string) (PrivateKey, error)
NewPrivateKeyFromString creates a new private key a base58 encoded string.
type PublicKey ¶
type PublicKey interface { Key Verify(data []byte, sig []byte) (bool, error) VerifyString(data []byte, sig string) (bool, error) // encrypt data so it is only decryptable w the private key of this key Encrypt(in []byte) ([]byte, error) InternalKey() *btcec.PublicKey }
PublicKey defines a public encryption key.
func NewPublicKey ¶
NewPublicKey creates a new public key from provided binary key data.
func NewPublicKeyFromString ¶
NewPublicKeyFromString creates a new public key from a base58 encoded string data.
Directories ¶
Path | Synopsis |
---|---|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202. |