68 lines
1.1 KiB
Go
68 lines
1.1 KiB
Go
package rsa
|
|
|
|
import "fmt"
|
|
|
|
type UnableToGenerateKeyPairError struct {
|
|
err error
|
|
}
|
|
|
|
func (e *UnableToGenerateKeyPairError) Error() string {
|
|
return fmt.Sprintf("未能生成密钥对, %s", e.err)
|
|
}
|
|
|
|
type AbsentPrivateKeyError struct{}
|
|
|
|
func (e *AbsentPrivateKeyError) Error() string {
|
|
return "缺少私钥"
|
|
}
|
|
|
|
type AbsentPublicKeyError struct{}
|
|
|
|
func (e *AbsentPublicKeyError) Error() string {
|
|
return "缺少公钥"
|
|
}
|
|
|
|
type EncryptionError struct {
|
|
err error
|
|
}
|
|
|
|
func (e *EncryptionError) Error() string {
|
|
return fmt.Sprintf("加密失败, %s", e.err)
|
|
}
|
|
|
|
type DecryptionError struct {
|
|
err error
|
|
}
|
|
|
|
func (e *DecryptionError) Error() string {
|
|
return fmt.Sprintf("解密失败, %s", e.err)
|
|
}
|
|
|
|
type KeyNotFoundError struct{}
|
|
|
|
func (e *KeyNotFoundError) Error() string {
|
|
return "找不到密钥"
|
|
}
|
|
|
|
type InvalidSignMethodError struct{}
|
|
|
|
func (e *InvalidSignMethodError) Error() string {
|
|
return "无效的签名方法"
|
|
}
|
|
|
|
type SignError struct {
|
|
err error
|
|
}
|
|
|
|
func (e *SignError) Error() string {
|
|
return fmt.Sprintf("签名失败, %s", e.err)
|
|
}
|
|
|
|
type VerifyError struct {
|
|
err error
|
|
}
|
|
|
|
func (e *VerifyError) Error() string {
|
|
return fmt.Sprintf("验证失败, %s", e.err)
|
|
}
|