crypto

package
v0.0.0-...-7271f6c Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2015 License: MIT Imports: 14 Imported by: 6

Documentation

Overview

This package implements helper methods to be used by the AirDispatch system to take care of all encryption needs. It is split into files based on the types of crypto included.

--- Crypto | - Constants = Constants used for Encoding and Decoding | - Crypto = Methods needed for all Crypto Files | - Encoding = Encoding Keys to Binary (and back again) | - Encryption = AES Encryption and Decryption | - Hash = SHA256 Hashing | - Signatures = ECDSA Signing

Index

Constants

This section is empty.

Variables

View Source
var AESKeySize int = 256
View Source
var ECDSAPrefix = []byte{3}
View Source
var EllipticCurve elliptic.Curve = elliptic.P256()
View Source
var EncryptionNone = []byte{0, 0} // "airdispat.ch/crypto/none"

Seperate Encryption Types

View Source
var EncryptionRSA = []byte{1, 1} // "airdispat.ch/crypto/rsa2048-aes256"
View Source
var RSAPrefix = []byte("AD-RSA")
View Source
var Random = rand.Reader
View Source
var SigningECDSA = []byte{0}

Seperate Signing Types

Functions

func BytesToAddress

func BytesToAddress(toHash []byte) []byte

func BytesToKey

func BytesToKey(data []byte) (*ecdsa.PublicKey, error)

This function creates an ECDSA Public KEy from a bytestring. This is used to send the public key in the SignedMessage message.

func BytesToRSA

func BytesToRSA(data []byte) (*rsa.PublicKey, error)

func HashRIP

func HashRIP(payload []byte) []byte

Encapsulation for the RIPEMD160 Hasher

func HashSHA

func HashSHA(payload []byte) []byte

Encapsulation for the SHA Hasher

func HybridDecryption

func HybridDecryption(rsaKey *rsa.PrivateKey, encryptedAesKey []byte, ciphertext []byte) (plaintext []byte, error error)

func KeyToBytes

func KeyToBytes(key *ecdsa.PublicKey) []byte

This function writes an ECDSA Public Key to a bytestring. This is used to send the public key in the SignedMessage message.

func RSAToBytes

func RSAToBytes(key *rsa.PublicKey) []byte

func SignPayload

func SignPayload(key *ecdsa.PrivateKey, payload []byte) (r, s *big.Int, err error)

Encapsulates ECDSA Signature Generation

func VerifyPayload

func VerifyPayload(key *ecdsa.PublicKey, payload []byte, r, s *big.Int) bool

Encapsulates ECDSA Signature Verification

func VerifyStringAddress

func VerifyStringAddress(address string) bool

Hex decode an Address then verify that it is correct, then pass it to the byte verification function

Types

type AESKey

type AESKey []byte

func EncryptDataWithRandomAESKey

func EncryptDataWithRandomAESKey(plaintext []byte) (aesCipher []byte, unencryptedKey AESKey, err error)

type EncryptedAESKey

type EncryptedAESKey []byte

func EncryptAESKey

func EncryptAESKey(a AESKey, b *rsa.PublicKey) (EncryptedAESKey, error)

Jump to

Keyboard shortcuts

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