Documentation ¶
Index ¶
- func AesCtrCrypt(plainText []byte, key []byte) ([]byte, error)
- func AesDecryptCBC(cryted []byte, key []byte) ([]byte, error)
- func AesDecryptCFB(encrypted []byte, key []byte) ([]byte, error)
- func AesDecryptECB(encrypted []byte, key []byte) ([]byte, error)
- func AesDecryptOFB(data []byte, key []byte) ([]byte, error)
- func AesEncryptCBC(orig []byte, key []byte) ([]byte, error)
- func AesEncryptCFB(origData []byte, key []byte) ([]byte, error)
- func AesEncryptECB(src []byte, key []byte) ([]byte, error)
- func AesEncryptOFB(data []byte, key []byte) ([]byte, error)
- func GenerateNonce(size int) []byte
- func GenerateStringNonce(size int) string
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) ([]byte, error)
- func PrivateBytesToPEM(buf []byte) []byte
- func PrivateKeyAsPEM(key *rsa.PrivateKey) []byte
- func PublicBytesToPEM(buf []byte) []byte
- func PublicKeyAsPEM(key *rsa.PublicKey) []byte
- func RandomBytes(size int) []byte
- func RandomString(size int) string
- func RsaDecrypt(ciphertext, privateKey []byte) ([]byte, error)
- func RsaDecryptOAEP(msg []byte, priv *rsa.PrivateKey) ([]byte, error)
- func RsaEncrypt(origData, publicKey []byte) ([]byte, error)
- func RsaEncryptOAEP(msg []byte, pub *rsa.PublicKey) ([]byte, error)
- func Sha1Digest(data []byte) []byte
- func Sha256Digest(data []byte) []byte
- type ECDH
- type PasswordKdfAlgoModPow
- type SRPUtil
- func (m *SRPUtil) CalcClientM(newSalt1, xBytes, srpB []byte) ([]byte, []byte)
- func (m *SRPUtil) CalcClientM2(newSalt1, aBytes, ABytes, xBytes, srpB []byte) []byte
- func (m *SRPUtil) CalcM(newSalt1, vBytes, srpA, srpb, srpB []byte) []byte
- func (m *SRPUtil) CalcSRPB(vBytes []byte) ([]byte, []byte)
- func (m *SRPUtil) CalcSRPB2(bNonce, vBytes []byte) []byte
- func (m *SRPUtil) CheckNewSalt1(newSalt1 []byte) bool
- func (m *SRPUtil) GetV(newSalt1, passwordBytes []byte) *big.Int
- func (m *SRPUtil) GetVBytes(newSalt1, passwordBytes []byte) []byte
- func (m *SRPUtil) GetX(newSalt1, passwordBytes []byte) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesCtrCrypt ¶
AesCtrCrypt 加密、解密使用同一个函数
func GenerateNonce ¶
func GenerateStringNonce ¶
func PKCS7Padding ¶
PKCS7Padding 补码 AES加密数据块分组长度必须为128bit(byte[16]),密钥长度可以是128bit(byte[16])、192bit(byte[24])、256bit(byte[32])中的任意一个。
func PrivateBytesToPEM ¶
func PrivateKeyAsPEM ¶
func PrivateKeyAsPEM(key *rsa.PrivateKey) []byte
PrivateKeyAsPEM takes a pointer to an RSA private key and returns its PEM encoding as a byte slice.
func PublicBytesToPEM ¶
func PublicKeyAsPEM ¶
PublicKeyAsPEM takes a pointer to an RSA private key and returns its corresponding public key's PEM encoding as a byte slice.
func RandomBytes ¶
func RandomString ¶
func RsaDecrypt ¶
func RsaDecryptOAEP ¶
func RsaDecryptOAEP(msg []byte, priv *rsa.PrivateKey) ([]byte, error)
RsaDecryptOAEP takes a message as a byte slice and an RSA private key, and returns the decrypted message as a byte slice.
func RsaEncrypt ¶
func RsaEncryptOAEP ¶
RsaEncryptOAEP takes a message as a byte slice and an RSA public key, and returns the encrypted message as a byte slice.
func Sha1Digest ¶
func Sha256Digest ¶
Types ¶
type ECDH ¶
type ECDH interface { // GenerateKey 生成公私钥对 GenerateKey() error // MarshalPublicKey 将公钥转换为字节 MarshalPublicKey() []byte // MarshalPrivateKey 将私钥转换为字节 MarshalPrivateKey() []byte GenerateSharedSecret([]byte) ([]byte, []byte, error) }
ECDH The main interface for ECDH key exchange.
func NewCurveKey ¶
func NewCurveKey() ECDH
type PasswordKdfAlgoModPow ¶
type SRPUtil ¶
type SRPUtil struct { *PasswordKdfAlgoModPow // contains filtered or unexported fields }
func MakeSRPUtil ¶
func MakeSRPUtil(algo *PasswordKdfAlgoModPow) *SRPUtil