An open API service indexing awesome lists of open source software.

https://github.com/one-com/dkimcrypt

dkimcrypt provides convenient functions for en- or decrypting, as well as signing and verifying data using a combination of local private key files and public keys present in DKIM DNS TXT records
https://github.com/one-com/dkimcrypt

Last synced: about 2 months ago
JSON representation

dkimcrypt provides convenient functions for en- or decrypting, as well as signing and verifying data using a combination of local private key files and public keys present in DKIM DNS TXT records

Awesome Lists containing this project

README

        

# dkimcrypt
`import "gitlab.one.com/go/dkimcrypt"`

* [Overview](#pkg-overview)
* [Index](#pkg-index)
* [Subdirectories](#pkg-subdirectories)

## Overview
Package dkimcrypt provides convenient functions for en- or decrypting, as
well as signing and verifying data using a combination of local private key
files and public keys present in DKIM DNS TXT records

## Index
* [func Decrypt(selector, privkeypath string, in, key, mac []byte) (out []byte, err error)](#Decrypt)
* [func DecryptSingle(selector, privkeypath string, in []byte) (out []byte, err error)](#DecryptSingle)
* [func Encrypt(selector, domain string, in []byte) (out, key, mac []byte, err error)](#Encrypt)
* [func EncryptSingle(selector, domain string, in []byte) (out []byte, err error)](#EncryptSingle)
* [func GetPrivateKey(filename string) (*rsa.PrivateKey, error)](#GetPrivateKey)
* [func GetPublicKey(selector, domain string) (*rsa.PublicKey, error)](#GetPublicKey)
* [func Sign(message []byte, privkeypath string) (out []byte, err error)](#Sign)
* [func Verify(message, signature []byte, selector, domain string) (err error)](#Verify)

#### Package files
[crypt_decrypt.go](/src/dkimcrypt/crypt_decrypt.go) [privkey.go](/src/dkimcrypt/privkey.go) [pubkey.go](/src/dkimcrypt/pubkey.go) [sign_verify.go](/src/dkimcrypt/sign_verify.go)

## func [Decrypt](/../blob/master/crypt_decrypt.go?s=3094:3181#L116)
``` go
func Decrypt(selector, privkeypath string, in, key, mac []byte) (out []byte, err error)
```
Decrypt will decrypt the data in 'in' and return it in 'out', given the path to a PEM-encoded
private key file, an RSA-encrypted key, a message authentication code hash,
and a selector, which must be the same used for encryption

## func [DecryptSingle](/../blob/master/crypt_decrypt.go?s=2074:2157#L87)
``` go
func DecryptSingle(selector, privkeypath string, in []byte) (out []byte, err error)
```
DecryptSingle is a wrapper around Decrypt, which will decrypt a byte slice
encrypted by EncryptSingle

## func [Encrypt](/../blob/master/crypt_decrypt.go?s=3911:3993#L145)
``` go
func Encrypt(selector, domain string, in []byte) (out, key, mac []byte, err error)
```
Encrypt will AES-encrypt the data given in 'in', and return the encrypted
version in 'out', as well as a key, which is RSA-encrypted using the public
key it finds in the DKIM-like TXT record at [selector]._domainkey.[domain],
and a message authentication code hash. Use the same selector in 'Decrypt'

## func [EncryptSingle](/../blob/master/crypt_decrypt.go?s=2596:2674#L102)
``` go
func EncryptSingle(selector, domain string, in []byte) (out []byte, err error)
```
EncryptSingle is a wrapper around Encrypt, which will encrypt a byte slice
and return a single byte slice representing a key, a verification hash and
the ecrypted data, useful for sending over a network. Decrypt using
DecryptSingle

## func [GetPrivateKey](/../blob/master/privkey.go?s=1166:1226#L38)
``` go
func GetPrivateKey(filename string) (*rsa.PrivateKey, error)
```
GetPrivateKey loads a private key from the given filename and returns it.

## func [GetPublicKey](/../blob/master/pubkey.go?s=3642:3708#L137)
``` go
func GetPublicKey(selector, domain string) (*rsa.PublicKey, error)
```
GetPublicKey will look up a public key for a domain with selector, and
return it. If no key is found, an error is returned.

## func [Sign](/../blob/master/sign_verify.go?s=207:276#L3)
``` go
func Sign(message []byte, privkeypath string) (out []byte, err error)
```
Sign will return the signature of the message in 'message' using the private
key in the file at 'privkeypath'.

## func [Verify](/../blob/master/sign_verify.go?s=836:911#L31)
``` go
func Verify(message, signature []byte, selector, domain string) (err error)
```
Verify a signature given the signature, the message it signed and the
selector and domain that signed it. If err is nil, then the signature is
good.

- - -
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)