Documentation ¶
Overview ¶
Crypto contains functionalities for secure and reliable encryption.
Index ¶
- Constants
- Variables
- func DecryptWith(privk *rsa.PrivateKey, ct []byte) ([]byte, error)
- func EncryptWith(pubk *rsa.PublicKey, text []byte) ([]byte, error)
- func LoadPrivateKey(filename string) (*rsa.PrivateKey, error)
- func LoadPublicKey(filename string) (*rsa.PublicKey, error)
- func SignWith(privk *rsa.PrivateKey, text []byte) ([]byte, error)
- func VerifySignatureWith(pubk *rsa.PublicKey, text []byte, sig []byte) error
- type Crypto
- type RSA
- func (r *RSA) Decrypt(ct []byte) ([]byte, error)
- func (r *RSA) Encrypt(text []byte) ([]byte, error)
- func (r *RSA) GetPrivateKey() *rsa.PrivateKey
- func (r *RSA) GetPublicKey() *rsa.PublicKey
- func (r *RSA) MarhsalPrivateKey() ([]byte, error)
- func (r *RSA) MarshalPublicKey() ([]byte, error)
- func (r *RSA) Save() error
- func (r *RSA) Sign(text []byte) ([]byte, error)
- func (r *RSA) VerifySignature(text []byte, sig []byte) error
Constants ¶
const (
RSADefaultC = 4096
)
Variables ¶
Functions ¶
func DecryptWith ¶
func DecryptWith(privk *rsa.PrivateKey, ct []byte) ([]byte, error)
func LoadPrivateKey ¶
func LoadPrivateKey(filename string) (*rsa.PrivateKey, error)
Types ¶
type Crypto ¶
type Crypto struct {
// contains filtered or unexported fields
}
Crypto is a struct containing all necessary information used during encryption/decryption. The struct members are not publicely exposed ( unimported ) and is only accessible via provided methods.
func NewCrypto ¶
func NewCrypto() *Crypto
NewCrypto returns a new struct pointer of type `Crypto`. It uses default settings for n, r, p, keyLen respectively 16384, 8, 1, 32.
func NewCryptoFromArgs ¶
NewCryptoFromArgs returns a new struct pointer of type `Crypto` and sets the internal according to given arguments. It is not neccessary to use this function directly as the default settings used by `NewCrypto()` is sufficient.
func (*Crypto) Decrypt ¶
Decrypt returns the decrypted data. Simlilar to `Encrypt`, error must be checked explicitely.
type RSA ¶
type RSA struct {
// contains filtered or unexported fields
}
func (*RSA) GetPrivateKey ¶
func (r *RSA) GetPrivateKey() *rsa.PrivateKey