Documentation ¶
Overview ¶
Package rsa provides rsa crypto related implementations.
Package rsa provides rsa crypto related implementations.
Package rsa provides rsa crypto related implementations.
Index ¶
- type KeyPair
- func (this *KeyPair) DecryptOAEP(ciphertext []byte) (string, error)
- func (this *KeyPair) DecryptPKCS1v15(ciphertext []byte) (string, error)
- func (this *KeyPair) EncryptOAEP(plaintext string) ([]byte, error)
- func (this *KeyPair) EncryptPKCS1v15(plaintext string) ([]byte, error)
- func (this *KeyPair) Generate(bits int) error
- func (this *KeyPair) GetKeyPair() (privateKey PrivateKey, publicKey PublicKey)
- func (this *KeyPair) SetKeyPair(privateKey PrivateKey, publicKey PublicKey)
- type PrivateKey
- func (this *PrivateKey) DecryptOAEP(ciphertext []byte) (string, error)
- func (this *PrivateKey) DecryptPKCS1v15(ciphertext []byte) (string, error)
- func (this *PrivateKey) EncryptOAEP(plaintext string) ([]byte, error)
- func (this *PrivateKey) EncryptPKCS1v15(plaintext string) ([]byte, error)
- func (this *PrivateKey) Get() *rsa.PrivateKey
- func (this *PrivateKey) GetPemPKCS1() string
- func (this *PrivateKey) GetPemPKCS8() (string, error)
- func (this *PrivateKey) GetPublicKey() PublicKey
- func (this *PrivateKey) Set(privateKey *rsa.PrivateKey)
- func (this *PrivateKey) SetBits(bits int) error
- func (this *PrivateKey) SetPemPKCS1(pemPKCS1 string) error
- func (this *PrivateKey) SetPemPKCS8(pemPKCS8 string) error
- type PublicKey
- func (this *PublicKey) EncryptOAEP(plaintext string) ([]byte, error)
- func (this *PublicKey) EncryptPKCS1v15(plaintext string) ([]byte, error)
- func (this *PublicKey) Get() rsa.PublicKey
- func (this *PublicKey) GetPemPKCS1() string
- func (this *PublicKey) GetPemPKIX() (string, error)
- func (this *PublicKey) GetSsh() (string, error)
- func (this *PublicKey) GetSshPublicKey() (ssh.PublicKey, error)
- func (this *PublicKey) Set(publicKey rsa.PublicKey)
- func (this *PublicKey) SetPemPKCS1(pemPKCS1 string) error
- func (this *PublicKey) SetPemPKIX(pemPKIX string) error
- func (this *PublicKey) SetSsh(sshKey string) error
- func (this *PublicKey) SetSshPublicKey(publicKey ssh.PublicKey) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair is struct that provides key pair related methods.
func (*KeyPair) DecryptOAEP ¶
DecryptOAEP is decrypt ciphertext.
ex) plaintext, err := keyPair.DecryptOAEP(ciphertext)
func (*KeyPair) DecryptPKCS1v15 ¶
DecryptPKCS1v15 is decrypt ciphertext.
ex) plaintext, err := keyPair.DecryptPKCS1v15(ciphertext)
func (*KeyPair) EncryptOAEP ¶
EncryptOAEP is encrypt plaintext.
ex) ciphertext, err := keyPair.EncryptOAEP(plaintext)
func (*KeyPair) EncryptPKCS1v15 ¶
EncryptPKCS1v15 is encrypt plaintext.
ex) ciphertext, err := keyPair.EncryptPKCS1v15(plaintext)
func (*KeyPair) GetKeyPair ¶
func (this *KeyPair) GetKeyPair() (privateKey PrivateKey, publicKey PublicKey)
GetKeyPair is to get a key pair.
ex) privateKey, publicKey := keyPair.GetKeyPair()
func (*KeyPair) SetKeyPair ¶
func (this *KeyPair) SetKeyPair(privateKey PrivateKey, publicKey PublicKey)
SetKeyPair is to set a key pair.
ex) keyPair.SetKeyPair(privateKey, publicKey)
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey is struct that provides private key related methods.
func (*PrivateKey) DecryptOAEP ¶
func (this *PrivateKey) DecryptOAEP(ciphertext []byte) (string, error)
DecryptOAEP is decrypt ciphertext.
ex) plaintext, err := privateKey.DecryptOAEP(ciphertext)
func (*PrivateKey) DecryptPKCS1v15 ¶
func (this *PrivateKey) DecryptPKCS1v15(ciphertext []byte) (string, error)
DecryptPKCS1v15 is decrypt ciphertext.
ex) plaintext, err := privateKey.DecryptPKCS1v15(ciphertext)
func (*PrivateKey) EncryptOAEP ¶
func (this *PrivateKey) EncryptOAEP(plaintext string) ([]byte, error)
EncryptOAEP is encrypt plaintext.
ex) ciphertext, err := privateKey.EncryptOAEP(plaintext)
func (*PrivateKey) EncryptPKCS1v15 ¶
func (this *PrivateKey) EncryptPKCS1v15(plaintext string) ([]byte, error)
EncryptPKCS1v15 is encrypt plaintext.
ex) ciphertext, err := privateKey.EncryptPKCS1v15(plaintext)
func (*PrivateKey) Get ¶
func (this *PrivateKey) Get() *rsa.PrivateKey
Get is to get a *rsa.PrivateKey.
ex) key := privateKey.Get()
func (*PrivateKey) GetPemPKCS1 ¶
func (this *PrivateKey) GetPemPKCS1() string
GetPemPKCS1 is to get a string in Pem/PKCS1 format.
ex) pemPKCS1 := privateKey.GetPemPKCS1()
func (*PrivateKey) GetPemPKCS8 ¶
func (this *PrivateKey) GetPemPKCS8() (string, error)
GetPemPKCS8 is to get a string in Pem/PKCS8 format.
ex) pemPKCS8, err := privateKey.GetPemPKCS8()
func (*PrivateKey) GetPublicKey ¶
func (this *PrivateKey) GetPublicKey() PublicKey
GetPublicKey is to get a PublicKey.
ex) key := privateKey.GetPublicKey()
func (*PrivateKey) Set ¶
func (this *PrivateKey) Set(privateKey *rsa.PrivateKey)
Set is to set a *rsa.PrivateKey.
ex) privateKey.Set(key)
func (*PrivateKey) SetBits ¶
func (this *PrivateKey) SetBits(bits int) error
SetBits is to set the primary key using bits.
ex) err := privateKey.SetBits(4096)
func (*PrivateKey) SetPemPKCS1 ¶
func (this *PrivateKey) SetPemPKCS1(pemPKCS1 string) error
SetPemPKCS1 is to set the primary key using a string in Pem/PKCS1 format.
ex) err := privateKey.SetPemPKCS1(pemPKCS1)
func (*PrivateKey) SetPemPKCS8 ¶
func (this *PrivateKey) SetPemPKCS8(pemPKCS8 string) error
SetPemPKCS8 is to set the primary key using a string in Pem/PKCS8 format.
ex) err := privateKey.SetPemPKCS8(pemPKCS8)
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is struct that provides public key related methods.
func (*PublicKey) EncryptOAEP ¶
EncryptOAEP is encrypt plaintext.
ex) ciphertext, err := publicKey.EncryptOAEP(plaintext)
func (*PublicKey) EncryptPKCS1v15 ¶
EncryptPKCS1v15 is encrypt plaintext.
ex) ciphertext, err := publicKey.EncryptPKCS1v15(plaintext)
func (*PublicKey) GetPemPKCS1 ¶
GetPemPKCS1 is to get a string in Pem/PKCS1 format.
ex) pemPKCS1 := publicKey.GetPemPKCS1()
func (*PublicKey) GetPemPKIX ¶
GetPemPKIX is to get a string in Pem/PKIX format.
ex) pemPKIX, err := publicKey.GetPemPKIX()
func (*PublicKey) GetSsh ¶
GetSsh is to get a string in ssh format.
ex) sshKey, err := publicKey.GetSsh()
func (*PublicKey) GetSshPublicKey ¶
GetSshPublicKey is to get a ssh.PublicKey.
ex) key, err := publicKey.GetSshPublicKey()
func (*PublicKey) SetPemPKCS1 ¶
SetPemPKCS1 is to set the public key using a string in Pem/PKCS1 format.
ex) err := publicKey.SetPemPKCS1(pemPKCS1)
func (*PublicKey) SetPemPKIX ¶
SetPemPKIX is to set the public key using a string in Pem/PKIX format.
ex) err := publicKey.SetPemPKIX(pemPKIX)