rsa

package
v2.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeysFromSeed

func GenerateKeysFromSeed(seedData []byte, bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateKeysFromSeed 使用种子数据生成 RSA 密钥对 参数:

  • seedData: 用于生成密钥的种子数据
  • bits: RSA 密钥的位数

返回值:

  • *rsa.PrivateKey: 生成的私钥
  • *rsa.PublicKey: 生成的公钥
  • error: 如果生成过程中出现错误,返回相应的错误信息

func PublicKeyToBytes

func PublicKeyToBytes(pubKey *rsa.PublicKey) ([]byte, error)

PublicKeyToBytes 使用 x509 标准将公钥转换为字节 参数:

  • pubKey: 要转换的 RSA 公钥

返回值:

  • []byte: 转换后的公钥字节
  • error: 如果转换过程中出现错误,返回相应的错误信息

func SignData

func SignData(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)

SignData 使用 RSA 私钥为数据签名 参数:

  • privateKey: 用于签名的 RSA 私钥
  • data: 要签名的数据

返回值:

  • []byte: 生成的签名
  • error: 如果签名过程中出现错误,返回相应的错误信息

func VerifySignature

func VerifySignature(publicKey *rsa.PublicKey, data []byte, signature []byte) bool

VerifySignature 使用 RSA 公钥验证数据的签名 参数:

  • publicKey: 用于验证签名的 RSA 公钥
  • data: 原始数据
  • signature: 要验证的签名

返回值:

  • bool: 如果签名有效返回 true,否则返回 false

Types

This section is empty.

Jump to

Keyboard shortcuts

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