sqrlcrypto

package module
v0.0.0-...-750b1cc Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

README

sqrlcrypto

Just playing around trying to implement some of the funcitonality outlined in: https://www.grc.com/sqrl/SQRL_Cryptography.pdf

This is currently non-functional. DO NOT USE THIS CODE IN PRODUCTION!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESGCMDecrypt

func AESGCMDecrypt(key, encrypted, iv, additionalData, tag []byte) ([]byte, error)

func AESGCMEncrypt

func AESGCMEncrypt(key, plaintext, iv, additionalData []byte) ([]byte, error)

func EnHash

func EnHash(key []byte) []byte

func RescueCode

func RescueCode(rand io.Reader) (string, error)

RescueCode is a 24 byte BCD value

Types

type AEADEncrypted

type AEADEncrypted struct {
	Value []byte
	IV    []byte
	Tag   []byte
}

func AESGCMEncryptOld

func AESGCMEncryptOld(rand io.Reader, password string, plaintext []byte, duration time.Duration) (*AEADEncrypted, error)

type EnscryptResult

type EnscryptResult struct {
	Value      []byte
	Salt       []byte
	Iterations int
	Duration   time.Duration
}

func EnScrypt

func EnScrypt(rand io.Reader, password string, duration time.Duration, logN byte) (*EnscryptResult, error)

func EnScryptAgain

func EnScryptAgain(salt []byte, password string, iterations int, logN byte) (*EnscryptResult, error)

type S4Data

type S4Data struct {
	MasterKey          *S4Type1
	RescueCode         *S4Type2
	PreviousIdentities *S4Type3
	Others             [][]byte
}

func S4Decode

func S4Decode(data []byte) (*S4Data, error)

type S4Type1

type S4Type1 struct {
	Length                uint16   // == 125
	Type                  uint16   // == 1
	PlainLength           uint16   // == 45
	AESGCMIV              [12]byte // 12
	ScryptSalt            [16]byte // 16
	ScryptN               byte
	ScryptIterations      uint32
	OptionFlags           uint16
	HintLength            byte
	PasswordVerifySeconds byte
	IdleTimeoutMinutes    uint16

	EncryptedIdentityMasterKey [32]byte // 32
	EncryptedIdentityLockKey   [32]byte // 32
	VerificationTag            [16]byte // 16
}

S4Type1 Password encrypted data

func S4Type1Decode

func S4Type1Decode(e []byte) (*S4Type1, error)

func (*S4Type1) AdditionalData

func (s4 *S4Type1) AdditionalData() []byte

func (*S4Type1) Encode

func (s4 *S4Type1) Encode() []byte

func (*S4Type1) String

func (s4 *S4Type1) String() string

type S4Type2

type S4Type2 struct {
	Length           uint16   // == 73
	Type             uint16   // == 2
	ScryptSalt       [16]byte // 16
	ScryptN          byte
	ScryptIterations uint32

	EncryptedIdentityUnlockKey [32]byte // 32
	VerificationTag            [16]byte // 16
}

S4Type2 RescueCode encrypted data

func S4Type2Decode

func S4Type2Decode(e []byte) (*S4Type2, error)

func (*S4Type2) AdditionalData

func (s4 *S4Type2) AdditionalData() []byte

func (*S4Type2) String

func (s4 *S4Type2) String() string

type S4Type3

type S4Type3 struct {
	Length  uint16 // == 54,86,118,150 (+32 for each previous key)
	Type    uint16 // == 2
	Edition uint16

	// array of previous keys sorted with oldest last
	EncryptedIdentityPreviousUnlockKey [][32]byte
	VerificationTag                    [16]byte // 16
}

S4Type3 Previous identities encrypted data

func S4Type3Decode

func S4Type3Decode(e []byte) (*S4Type3, error)

func (*S4Type3) String

func (s4 *S4Type3) String() string

type SqrlIdentity

type SqrlIdentity struct {
	IdentityUnlockKey []byte
	IdentityLockKey   []byte
	IdentityMasterKey []byte
	RescueCode        string
}

func CreateIdentity

func CreateIdentity(rand io.Reader, password string) (*SqrlIdentity, error)

func (*SqrlIdentity) GenerateUnlockPublicKeys

func (si *SqrlIdentity) GenerateUnlockPublicKeys(rand io.Reader) (suk crypto.PublicKey, vuk crypto.PublicKey, err error)

func (*SqrlIdentity) GenerateUnlockRequestSigningKey

func (si *SqrlIdentity) GenerateUnlockRequestSigningKey(serverUnlockKey []byte) ed25519.PrivateKey

func (*SqrlIdentity) IdentityUnlockAccessCode

func (i *SqrlIdentity) IdentityUnlockAccessCode() []byte

Jump to

Keyboard shortcuts

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