pb

package
v0.0.0-...-eca2864 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pb implements some useful password-based (PB) functions:

  1. AES-related (192-bit AES): 1.1. PBAesEncrypt encrypts input byte array using string password specified into a new (encrypted) byte array 1.2. PBAesDecrypt decrypts input byte array using string password specified into a new (decrypted) byte array

  2. HTTP-related 2.1. PBSignRequest signs an http request using a string password; adds 2 additional headers to the request 2.2. PBVerifyRequest verifies previously signed http request using a string password

Index

Constants

View Source
const AES_BLOCK_LENGTH = 1 << 4 // 128 bit

AES_BLOCK_LENGTH AES block length (128 bit)

View Source
const DEFAULT_AES_KEY_LENGTH = 24

KEY LENGTH (AES): 192 bit

View Source
const DEFAULT_HMAC_KEY_LENGTH = 1 << 5

KEY LENGTH (HMAC): 256 bit

View Source
const DEFAULT_PBKDF2_ITERATIONS = 1 << 15

Defaults for DefaultPBE: PBKDF2 ITERATIONS: 32k

View Source
const DEFAULT_PBKDF2_SALT_LENGTH = 1 << 4

PBKDF2 SALT LENGTH: 128 bit

View Source
const REQ_HEADER_HMAC = "X-Cryptogo-Hmac"
View Source
const REQ_HEADER_SALT = "X-Cryptogo-Salt"

Variables

DefaultPBE

Functions

func AllocateSlice

func AllocateSlice(length int) []byte

AllocateSlice allocates slice of the specified length with a capacity enough to perform encryption of this slice without creating a new one This is the desired method to create slices to encrypt with PBAesEncryptPtr Executes on the DefaultPBE

func New

func New(pbkdf2_iterations, pbkdf2_salt_length, aes_key_length, hmac_key_length int) *pbe

New creates new pbe structure with the settings specified

func PBAesDecrypt

func PBAesDecrypt(encrypted []byte, password string) (original []byte, err error)

PBAesDecrypt: AES-based password-based decryption Executes on the DefaultPBE

func PBAesDecryptPtr

func PBAesDecryptPtr(block *[]byte, password string) error

PBAesDecryptPtr: AES-based password-based decryption Changes the slice supplied itself Executes on the DefaultPBE

func PBAesEncrypt

func PBAesEncrypt(original []byte, password string) (encrypted []byte, err error)

PBAesEncrypt: AES-based password-based encryption Executes on the DefaultPBE

func PBAesEncryptPtr

func PBAesEncryptPtr(block *[]byte, password string) error

PBAesEncryptPtr: AES-based password-based encryption Changes the slice supplied itself Executes on the DefaultPBE

func PBKDF2Key

func PBKDF2Key(password string, salt []byte, keylen int) (key []byte)

PBKDF2Key generates a key from given password using PBKDF2 function Executes on the DefaultPBE

func PBSignRequest

func PBSignRequest(req *http.Request, password string, pattern *util.SignaturePattern) error

PBSignRequest signs a http request using the password specified Signature changes if:

remote address changes
request URI changes
request header is deleted
request header is added
request header is modified

Signature doesn't change if:

request header ordering is changed

Executes on the DefaultPBE

func PBVerifyRequest

func PBVerifyRequest(req *http.Request, password string, pattern *util.SignaturePattern) bool

PBVerifyRequest checks earlier signed http request signature using password specified to ensure request was not altered Executes on the DefaultPBE

Types

This section is empty.

Jump to

Keyboard shortcuts

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