Minor: spelling and typos
This commit is contained in:
parent
97e70855b8
commit
d005dca0a4
9 changed files with 65 additions and 74 deletions
|
|
@ -2,13 +2,13 @@ package armor
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
"proton/pmcrypto/internal"
|
||||
"golang.org/x/crypto/openpgp/clearsign"
|
||||
"errors"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
"golang.org/x/crypto/openpgp/clearsign"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"proton/pmcrypto/internal"
|
||||
"proton/pmcrypto/models"
|
||||
)
|
||||
|
||||
|
|
@ -32,9 +32,9 @@ func ArmorWithType(input []byte, armorType string) (string, error) {
|
|||
return b.String(), nil
|
||||
}
|
||||
|
||||
// UnArmor an armored key to bytes key
|
||||
func UnArmor(input string) ([]byte, error) {
|
||||
b, err := internal.UnArmor(input)
|
||||
// Unarmor an armored key to bytes key
|
||||
func Unarmor(input string) ([]byte, error) {
|
||||
b, err := internal.Unarmor(input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -50,14 +50,12 @@ func ReadClearSignedMessage(signedMessage string) (string, error) {
|
|||
return string(modulusBlock.Bytes), nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SeparateKeyAndData ...
|
||||
func SplitArmor(encrypted string) (*models.EncryptedSplit, error) {
|
||||
|
||||
var err error
|
||||
|
||||
encryptedRaw, err := UnArmor(encrypted)
|
||||
encryptedRaw, err := Unarmor(encrypted)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -112,8 +110,6 @@ func SplitArmor(encrypted string) (*models.EncryptedSplit, error) {
|
|||
return outSplit, err
|
||||
}
|
||||
|
||||
|
||||
|
||||
//encode length based on 4.2.2. in the RFC
|
||||
func encodedLength(length int) (b []byte) {
|
||||
if length < 192 {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import (
|
|||
"io/ioutil"
|
||||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
armorUtils "proton/pmcrypto/armor"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"proton/pmcrypto/internal"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
armorUtils "proton/pmcrypto/armor"
|
||||
"proton/pmcrypto/internal"
|
||||
"proton/pmcrypto/models"
|
||||
)
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ func (pm *PmCrypto) EncryptAttachmentBinKey(plainData []byte, fileName string, p
|
|||
|
||||
//EncryptAttachment ...
|
||||
func (pm *PmCrypto) EncryptAttachment(plainData []byte, fileName string, publicKey string) (*models.EncryptedSplit, error) {
|
||||
rawPubKey, err := armorUtils.UnArmor(publicKey)
|
||||
rawPubKey, err := armorUtils.Unarmor(publicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ func (pm *PmCrypto) DecryptAttachmentBinKey(keyPacket []byte, dataPacket []byte,
|
|||
|
||||
encryptedReader := io.MultiReader(keyReader, dataReader)
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
|
||||
md, err := openpgp.ReadMessage(encryptedReader, privKeyEntries, nil, config)
|
||||
if err != nil {
|
||||
|
|
@ -107,7 +107,7 @@ func (pm *PmCrypto) DecryptAttachmentBinKey(keyPacket []byte, dataPacket []byte,
|
|||
|
||||
//DecryptAttachment ...
|
||||
func (pm *PmCrypto) DecryptAttachment(keyPacket []byte, dataPacket []byte, privateKey string, passphrase string) ([]byte, error) {
|
||||
rawPrivKey, err := armorUtils.UnArmor(privateKey)
|
||||
rawPrivKey, err := armorUtils.Unarmor(privateKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ func (pm *PmCrypto) EncryptAttachmentWithPassword(plainData []byte, password str
|
|||
return "", err
|
||||
}
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
|
||||
plaintext, err := openpgp.SymmetricallyEncrypt(w, []byte(password), nil, config)
|
||||
if err != nil {
|
||||
|
|
@ -154,7 +154,7 @@ func (pm *PmCrypto) DecryptAttachmentWithPassword(keyPacket []byte, dataPacket [
|
|||
return []byte(password), nil
|
||||
}
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
|
||||
md, err := openpgp.ReadMessage(encryptedReader, nil, prompt, config)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"crypto"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"strings"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
|
|
@ -21,7 +21,6 @@ const (
|
|||
failed = 3
|
||||
)
|
||||
|
||||
|
||||
//IsKeyExpiredBin ...
|
||||
func (pm *PmCrypto) IsKeyExpiredBin(publicKey []byte) (bool, error) {
|
||||
now := pm.getNow()
|
||||
|
|
@ -77,7 +76,7 @@ func (pm *PmCrypto) IsKeyExpiredBin(publicKey []byte) (bool, error) {
|
|||
//IsKeyExpired ....
|
||||
// will user the cached time to check
|
||||
func (pm *PmCrypto) IsKeyExpired(publicKey string) (bool, error) {
|
||||
rawPubKey, err := armor.UnArmor(publicKey)
|
||||
rawPubKey, err := armor.Unarmor(publicKey)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -133,7 +132,6 @@ func (pm *PmCrypto) generateKey(userName string, domain string, passphrase strin
|
|||
return "", err
|
||||
}
|
||||
|
||||
|
||||
rawPwd := []byte(passphrase)
|
||||
if newEntity.PrivateKey != nil && !newEntity.PrivateKey.Encrypted {
|
||||
if err := newEntity.PrivateKey.Encrypt(rawPwd); err != nil {
|
||||
|
|
@ -158,7 +156,7 @@ func (pm *PmCrypto) generateKey(userName string, domain string, passphrase strin
|
|||
}
|
||||
|
||||
func (pm *PmCrypto) GenerateRSAKeyWithPrimes(userName string, domain string, passphrase string, bits int,
|
||||
primeone []byte, primetwo []byte, primethree []byte, primefour []byte) (string, error) {
|
||||
primeone []byte, primetwo []byte, primethree []byte, primefour []byte) (string, error) {
|
||||
return pm.generateKey(userName, domain, passphrase, "rsa", bits, primeone, primetwo, primethree, primefour)
|
||||
}
|
||||
|
||||
|
|
@ -171,6 +169,7 @@ func (pm *PmCrypto) GenerateRSAKeyWithPrimes(userName string, domain string, pas
|
|||
func (pm *PmCrypto) GenerateKey(userName string, domain string, passphrase string, keyType string, bits int) (string, error) {
|
||||
return pm.generateKey(userName, domain, passphrase, keyType, bits, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
// UpdatePrivateKeyPassphrase ...
|
||||
func (pm *PmCrypto) UpdatePrivateKeyPassphrase(privateKey string, oldPassphrase string, newPassphrase string) (string, error) {
|
||||
|
||||
|
|
@ -217,7 +216,7 @@ func (pm *PmCrypto) UpdatePrivateKeyPassphrase(privateKey string, oldPassphrase
|
|||
}
|
||||
|
||||
// CheckKey print out the key and subkey fingerprint
|
||||
func (pm *PmCrypto) CheckKey(pubKey string) (string, error) {
|
||||
func (pm *PmCrypto) CheckKey(pubKey string) (string, error) {
|
||||
pubKeyReader := strings.NewReader(pubKey)
|
||||
entries, err := openpgp.ReadArmoredKeyRing(pubKeyReader)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
errors2 "golang.org/x/crypto/openpgp/errors"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"math"
|
||||
armorUtils "proton/pmcrypto/armor"
|
||||
"proton/pmcrypto/internal"
|
||||
|
|
@ -23,7 +23,7 @@ import (
|
|||
// privateKey : armored private use to decrypt message
|
||||
// passphrase : match with private key to decrypt message
|
||||
func (pm *PmCrypto) DecryptMessage(encryptedText string, privateKey string, passphrase string) (string, error) {
|
||||
privKeyRaw, err := armorUtils.UnArmor(privateKey)
|
||||
privKeyRaw, err := armorUtils.Unarmor(privateKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ func (pm *PmCrypto) DecryptMessageBinKey(encryptedText string, privateKey []byte
|
|||
return "", err
|
||||
}
|
||||
|
||||
encryptedio, err := internal.UnArmor(encryptedText)
|
||||
encryptedio, err := internal.Unarmor(encryptedText)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ func (pm *PmCrypto) DecryptMessageBinKey(encryptedText string, privateKey []byte
|
|||
}
|
||||
}
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
|
||||
md, err := openpgp.ReadMessage(encryptedio.Body, privKeyEntries, nil, config)
|
||||
if err != nil {
|
||||
|
|
@ -76,13 +76,13 @@ func (pm *PmCrypto) DecryptMessageBinKey(encryptedText string, privateKey []byte
|
|||
return string(b), nil
|
||||
}
|
||||
|
||||
// DecryptMessageVerifyPrivbinkeys decrypt message and verify the signature
|
||||
// veriferKey string: armored verifier keys
|
||||
// DecryptMessageVerifyPrivBinKeys decrypt message and verify the signature
|
||||
// verifierKey string: armored verifier keys
|
||||
// privateKey []byte: unarmored private key to decrypt. could be mutiple
|
||||
func (pm *PmCrypto) DecryptMessageVerifyPrivbinkeys(encryptedText string, veriferKey string, privateKeys []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
func (pm *PmCrypto) DecryptMessageVerifyPrivBinKeys(encryptedText string, verifierKey string, privateKeys []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
|
||||
if len(veriferKey) > 0 {
|
||||
verifierRaw, err := armorUtils.UnArmor(veriferKey)
|
||||
if len(verifierKey) > 0 {
|
||||
verifierRaw, err := armorUtils.Unarmor(verifierKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -91,19 +91,19 @@ func (pm *PmCrypto) DecryptMessageVerifyPrivbinkeys(encryptedText string, verife
|
|||
return pm.decryptMessageVerifyAllBin(encryptedText, nil, privateKeys, passphrase, verifyTime)
|
||||
}
|
||||
|
||||
// DecryptMessageVerifyBinKeyPrivbinkeys decrypt message and verify the signature
|
||||
// veriferKey []byte: unarmored verifier keys
|
||||
// DecryptMessageVerifyBinKeyPrivBinKeys decrypt message and verify the signature
|
||||
// verifierKey []byte: unarmored verifier keys
|
||||
// privateKey []byte: unarmored private key to decrypt. could be mutiple
|
||||
func (pm *PmCrypto) DecryptMessageVerifyBinKeyPrivbinkeys(encryptedText string, veriferKey []byte, privateKeys []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
return pm.decryptMessageVerifyAllBin(encryptedText, veriferKey, privateKeys, passphrase, verifyTime)
|
||||
func (pm *PmCrypto) DecryptMessageVerifyBinKeyPrivBinKeys(encryptedText string, verifierKey []byte, privateKeys []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
return pm.decryptMessageVerifyAllBin(encryptedText, verifierKey, privateKeys, passphrase, verifyTime)
|
||||
}
|
||||
|
||||
// DecryptMessageVerify decrypt message and verify the signature
|
||||
// veriferKey string: armored verifier keys
|
||||
// verifierKey string: armored verifier keys
|
||||
// privateKey string: private to decrypt
|
||||
func (pm *PmCrypto) DecryptMessageVerify(encryptedText string, veriferKey string, privateKey string, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
if len(veriferKey) > 0 {
|
||||
verifierRaw, err := armorUtils.UnArmor(veriferKey)
|
||||
func (pm *PmCrypto) DecryptMessageVerify(encryptedText string, verifierKey string, privateKey string, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
if len(verifierKey) > 0 {
|
||||
verifierRaw, err := armorUtils.Unarmor(verifierKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -113,20 +113,20 @@ func (pm *PmCrypto) DecryptMessageVerify(encryptedText string, veriferKey string
|
|||
}
|
||||
|
||||
// DecryptMessageVerifyBinKey decrypt message and verify the signature
|
||||
// veriferKey []byte: unarmored verifier keys
|
||||
// verifierKey []byte: unarmored verifier keys
|
||||
// privateKey string: private to decrypt
|
||||
func (pm *PmCrypto) DecryptMessageVerifyBinKey(encryptedText string, veriferKey []byte, privateKey string, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
privateKeyRaw, err := armorUtils.UnArmor(privateKey)
|
||||
func (pm *PmCrypto) DecryptMessageVerifyBinKey(encryptedText string, verifierKey []byte, privateKey string, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
privateKeyRaw, err := armorUtils.Unarmor(privateKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pm.decryptMessageVerifyAllBin(encryptedText, veriferKey, privateKeyRaw, passphrase, verifyTime)
|
||||
return pm.decryptMessageVerifyAllBin(encryptedText, verifierKey, privateKeyRaw, passphrase, verifyTime)
|
||||
}
|
||||
|
||||
// decryptMessageVerifyAllBin
|
||||
// decrypt_message_verify_single_key(private_key: string, passphras: string, encrypted : string, signature : string) : decrypt_sign_verify;
|
||||
// decrypt_message_verify(passphras: string, encrypted : string, signature : string) : decrypt_sign_verify;
|
||||
func (pm *PmCrypto) decryptMessageVerifyAllBin(encryptedText string, veriferKey []byte, privateKey []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
func (pm *PmCrypto) decryptMessageVerifyAllBin(encryptedText string, verifierKey []byte, privateKey []byte, passphrase string, verifyTime int64) (*models.DecryptSignedVerify, error) {
|
||||
privKey := bytes.NewReader(privateKey)
|
||||
privKeyEntries, err := openpgp.ReadKeyRing(privKey)
|
||||
if err != nil {
|
||||
|
|
@ -151,8 +151,8 @@ func (pm *PmCrypto) decryptMessageVerifyAllBin(encryptedText string, veriferKey
|
|||
out.Verify = failed
|
||||
|
||||
var verifierEntries openpgp.EntityList
|
||||
if len(veriferKey) > 0 {
|
||||
verifierReader := bytes.NewReader(veriferKey)
|
||||
if len(verifierKey) > 0 {
|
||||
verifierReader := bytes.NewReader(verifierKey)
|
||||
verifierEntries, err = openpgp.ReadKeyRing(verifierReader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -165,7 +165,7 @@ func (pm *PmCrypto) decryptMessageVerifyAllBin(encryptedText string, veriferKey
|
|||
out.Verify = noVerifier
|
||||
}
|
||||
|
||||
encryptedio, err := internal.UnArmor(encryptedText)
|
||||
encryptedio, err := internal.Unarmor(encryptedText)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ func processSignatureExpiration(md *openpgp.MessageDetails, verifyTime int64) {
|
|||
if md.Signature.KeyLifetimeSecs != nil {
|
||||
expires = int64(*md.Signature.KeyLifetimeSecs) + created
|
||||
}
|
||||
if created - internal.CreationTimeOffset <= verifyTime && verifyTime <= expires {
|
||||
if created-internal.CreationTimeOffset <= verifyTime && verifyTime <= expires {
|
||||
md.SignatureError = nil
|
||||
}
|
||||
} else {
|
||||
|
|
@ -238,7 +238,7 @@ func processSignatureExpiration(md *openpgp.MessageDetails, verifyTime int64) {
|
|||
// privateKey : optional required when you want to sign
|
||||
// passphrase : optional required when you pass the private key and this passphrase must could decrypt the private key
|
||||
func (pm *PmCrypto) EncryptMessage(plainText string, publicKey string, privateKey string, passphrase string, trim bool) (string, error) {
|
||||
rawPubKey, err := armorUtils.UnArmor(publicKey)
|
||||
rawPubKey, err := armorUtils.Unarmor(publicKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -290,11 +290,11 @@ func (pm *PmCrypto) EncryptMessageBinKey(plainText string, publicKey []byte, pri
|
|||
}
|
||||
|
||||
if signEntity == nil {
|
||||
return "", errors.New("cannot sign message, singer key is not unlocked")
|
||||
return "", errors.New("cannot sign message, signer key is not unlocked")
|
||||
}
|
||||
}
|
||||
|
||||
config := &packet.Config{DefaultCipher: packet.CipherAES256, Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{DefaultCipher: packet.CipherAES256, Time: pm.getTimeGenerator()}
|
||||
|
||||
ew, err := openpgp.Encrypt(w, pubKeyEntries, signEntity, nil, config)
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ func (pm *PmCrypto) EncryptMessageWithPassword(plainText string, password string
|
|||
return "", err
|
||||
}
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
plaintext, err := openpgp.SymmetricallyEncrypt(w, []byte(password), nil, config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -338,7 +338,7 @@ func (pm *PmCrypto) EncryptMessageWithPassword(plainText string, password string
|
|||
//encrypted string : armored pgp message
|
||||
//output string : clear text
|
||||
func (pm *PmCrypto) DecryptMessageWithPassword(encrypted string, password string) (string, error) {
|
||||
encryptedio, err := internal.UnArmor(encrypted)
|
||||
encryptedio, err := internal.Unarmor(encrypted)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ func (pm *PmCrypto) DecryptMessageWithPassword(encrypted string, password string
|
|||
return []byte(password), nil
|
||||
}
|
||||
|
||||
config := &packet.Config{ Time: pm.getTimeGenerator() }
|
||||
config := &packet.Config{Time: pm.getTimeGenerator()}
|
||||
md, err := openpgp.ReadMessage(encryptedio.Body, nil, prompt, config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package crypto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"proton/pmcrypto/internal"
|
||||
"io/ioutil"
|
||||
"proton/pmcrypto/internal"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const publicKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
|
@ -235,7 +235,6 @@ z9GxJikRwscymWmXx2QsvhUiWeOJ05WwK+WAnKR1uVtkEJ9QJVe2chyuMORY
|
|||
-----END PGP PRIVATE KEY BLOCK-----
|
||||
`
|
||||
|
||||
|
||||
// define call back interface
|
||||
type Callbacks struct {
|
||||
}
|
||||
|
|
@ -259,9 +258,9 @@ func (t Callbacks) OnError(err error) {
|
|||
func TestDecrypt(t *testing.T) {
|
||||
callbacks := Callbacks{}
|
||||
o := PmCrypto{}
|
||||
block, _ := internal.UnArmor(publicKey)
|
||||
block, _ := internal.Unarmor(publicKey)
|
||||
publicKeyUnarmored, _ := ioutil.ReadAll(block.Body)
|
||||
block, _ = internal.UnArmor(privatekey)
|
||||
block, _ = internal.Unarmor(privatekey)
|
||||
privateKeyUnarmored, _ := ioutil.ReadAll(block.Body)
|
||||
o.DecryptMIMEMessage(testMessage, publicKeyUnarmored, privateKeyUnarmored, privatekeypassword,
|
||||
&callbacks, o.GetTime())
|
||||
|
|
@ -410,4 +409,3 @@ RIzX2CG47PuGl/uvImFW/Iw=
|
|||
fmt.Println(attachment)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
|
|
@ -118,7 +118,7 @@ func (pm *PmCrypto) GetSessionFromKeyPacket(keyPackage []byte, privateKey string
|
|||
|
||||
//KeyPacketWithPublicKey ...
|
||||
func (pm *PmCrypto) KeyPacketWithPublicKey(sessionSplit *models.SessionSplit, publicKey string) ([]byte, error) {
|
||||
pubkeyRaw, err := armor.UnArmor(publicKey)
|
||||
pubkeyRaw, err := armor.Unarmor(publicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func UnArmor(input string) (*armor.Block, error) {
|
||||
func Unarmor(input string) (*armor.Block, error) {
|
||||
io := strings.NewReader(input)
|
||||
b, err := armor.Decode(io)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// GetFingerprint get a armored public key fingerprint
|
||||
func GetFingerprint(publicKey string) (string, error) {
|
||||
rawPubKey, err := armor.UnArmor(publicKey)
|
||||
rawPubKey, err := armor.Unarmor(publicKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package models
|
||||
|
||||
|
||||
//EncryptedSplit when encrypt attachemt
|
||||
type EncryptedSplit struct {
|
||||
DataPacket []byte
|
||||
|
|
@ -8,7 +7,7 @@ type EncryptedSplit struct {
|
|||
Algo string
|
||||
}
|
||||
|
||||
//SessionSplit splited session
|
||||
//SessionSplit split session
|
||||
type SessionSplit struct {
|
||||
Session []byte
|
||||
Algo string
|
||||
|
|
@ -29,4 +28,3 @@ type DecryptSignedVerify struct {
|
|||
//error message if verify failed
|
||||
Message string
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue