crypto

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package crypto provides cryptographic functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptBytes

func EncryptBytes(key string, data []byte) ([]byte, error)

EncryptBytes encrypts a row of data using AES-CFB.

func GenerateNonce

func GenerateNonce() (string, error)

GenerateNonce generates a nonce for the OAuth2 flow. The nonce is a base64 encoded

func IsNonceValid

func IsNonceValid(nonce string, noncePeriod int64) (bool, error)

IsNonceValid checks if a nonce is valid. A nonce is valid if it is a base64 encoded string

Types

type AesCfbEngine added in v0.0.35

type AesCfbEngine struct {
	// contains filtered or unexported fields
}

AesCfbEngine is a structure that allows controller access to cryptographic functions. The intention is that this structure will be passed to the controller on creation and will validate that wrong parameters aren't passed to the functions.

func (*AesCfbEngine) DecryptOAuthToken added in v0.0.35

func (e *AesCfbEngine) DecryptOAuthToken(encToken string) (oauth2.Token, error)

DecryptOAuthToken decrypts an encrypted oauth token

func (*AesCfbEngine) DecryptString added in v0.0.35

func (e *AesCfbEngine) DecryptString(encData string) (string, error)

DecryptString decrypts an encrypted string

func (*AesCfbEngine) EncryptOAuthToken added in v0.0.35

func (e *AesCfbEngine) EncryptOAuthToken(data []byte) ([]byte, error)

EncryptOAuthToken encrypts an oauth token

func (*AesCfbEngine) EncryptString added in v0.0.35

func (e *AesCfbEngine) EncryptString(data string) (string, error)

EncryptString encrypts a string

type Engine

type Engine interface {
	EncryptOAuthToken(data []byte) ([]byte, error)
	DecryptOAuthToken(encToken string) (oauth2.Token, error)
	EncryptString(data string) (string, error)
	DecryptString(encData string) (string, error)
}

Engine provides all functions to encrypt and decrypt data

func EngineFromAuthConfig

func EngineFromAuthConfig(authConfig *serverconfig.AuthConfig) (Engine, error)

EngineFromAuthConfig creates a new crypto engine from an auth config

func NewEngine

func NewEngine(tokenKey string) Engine

NewEngine creates a new crypto engine

Directories

Path Synopsis
Package mockcrypto is a generated GoMock package.
Package mockcrypto is a generated GoMock package.

Jump to

Keyboard shortcuts

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