duanniwu7730 2017-12-21 13:22
浏览 68

如何使用openpgp在Go中清除签名和加密

My goal is to use read a PEM file (which contains a private key) and a passphrase to clearsign a file and then use openpgp to encrypt it using a public key that has been provided to me.

I know I should use block, _ := pem.Decode([]byte(pemFile)) to read the file and the ParsePKCS1PrivateKey but I am not sure how to clear sign the file using the key and the passphrase and then encrypt the signed using golang.org/x/crypto/openpgp

Reading the pem file and creating a private key is straightforward:

data, err := ioutil.ReadFile("myPemFile")
block, _ := pem.Decode([]byte(data))
key, err := x509.ParsePKCS1PrivateKey(block.Bytes)

where the key is *rsa.PrivateKey. The question is how to use a passphrase and the private key to clear sign a file i.e. doing something equivalent to:

gpg --batch --passphrase-file <passfile> --clearsign <unsigned file> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大