cryptoutil

package
v2.4.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 18 Imported by: 6

Documentation

Index

Constants

View Source
const (
	RandomNumberOffset  = 0
	RandomNumberSize    = 8
	CheckSumOffset      = RandomNumberOffset + RandomNumberSize
	CheckSumSize        = 16
	MessageOffset       = CheckSumOffset + CheckSumSize
	MessageMetaDataSize = RandomNumberSize + CheckSumSize
)
View Source
const (
	TicketVersion = 1
	TicketAge     = 24 * 60 * 60
)

Variables

This section is empty.

Functions

func AesDecryptCBC

func AesDecryptCBC(key, ciphertext []byte) (plaintext []byte, err error)

AesDecryptCBC defines aes decryption with CBC

func AesEncryptCBC

func AesEncryptCBC(key, plaintext []byte) (ciphertext []byte, err error)

AesEncryptCBC defines aes encryption with CBC

func AuthGenSessionKeyTS

func AuthGenSessionKeyTS(key []byte) (sessionKey []byte)

AuthGenSessionKeyTS authnode generates a session key according to its master key and current timestamp

func Base64Decode

func Base64Decode(encodedText string) (text []byte, err error)

Base64Decode Decoding using base64

func Base64Encode

func Base64Encode(text []byte) (encodedText string)

Base64Encode encoding using base64

func CreateClientX

func CreateClientX(cert *[]byte) (client *http.Client, err error)

CreateClientX creates a https client

func DecodeMessage

func DecodeMessage(message string, key []byte) (plaintext []byte, err error)

DecodeMessage decode a message and verify its validity

func EncodeMessage

func EncodeMessage(plaintext []byte, key []byte) (message string, err error)

EncodeMessage encode a message with aes encrption, md5 signature

func GenSecretKey

func GenSecretKey(key []byte, ts int64, id string) (secretKey []byte)

GenSecretKey generate a secret key according to pair {ts, id}

func GenVerifier

func GenVerifier(key []byte) (v string, ts int64, err error)

GenVerifier generate a verifier for replay mitigation in http

Types

type CryptoKey

type CryptoKey struct {
	Ctime int64  `json:"c_time"`
	Key   []byte `json:"key"`
}

CryptoKey store the session key

type Ticket

type Ticket struct {
	Version    uint8     `json:"version"`
	ServiceID  string    `json:"service_id"`
	SessionKey CryptoKey `json:"session_key"`
	Exp        int64     `json:"exp"`
	IP         string    `json:"ip"`
	Caps       []byte    `json:"caps"`
}

Ticket is a temperary struct to store permissions/caps for clients to access principle

Jump to

Keyboard shortcuts

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