Skip to content

Commit

Permalink
Use OAEP instead of PKCS1v15
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Feb 6, 2015
1 parent 7c3b36c commit 06b1701
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ with an attachment which contains encrypted message.
When you want to read a received attachment, you just execute following command;

```
$ openssl rsautl -decrypt -inkey <Your Secret Key> -in <Attachment>
$ openssl rsautl -decrypt -oaep -inkey <Your Secret Key> -in <Attachment>
```

Note
Expand Down
4 changes: 3 additions & 1 deletion encrypter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"

"github.com/ianmcmahon/encoding_ssh"
)
Expand All @@ -13,7 +14,8 @@ func encryptStringBySSHRsaPublicKey(sshRsaPubkey string, msg string) ([]byte, er
return make([]byte, 0), err
}

enc, err := rsa.EncryptPKCS1v15(rand.Reader, pubkey.(*rsa.PublicKey), []byte(msg))
enc, err := rsa.EncryptOAEP(sha1.New(), rand.Reader, pubkey.(*rsa.PublicKey), []byte(msg), nil)

if err != nil {
return make([]byte, 0), err
}
Expand Down
2 changes: 1 addition & 1 deletion mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func sendByGmail(m *mail) (err error) {

body := m.body
if body == "" {
body = fmt.Sprintf("Please execute with attachment file to read: `openssl rsautl -decrypt -inkey <YOUR SECRET KEY> -in %s`", filepath.Base(tempfileName))
body = fmt.Sprintf("Please execute with attachment file to read: `openssl rsautl -decrypt -oaep -inkey <YOUR SECRET KEY> -in %s`", filepath.Base(tempfileName))
}

newMsg := gomail.NewMessage()
Expand Down

0 comments on commit 06b1701

Please sign in to comment.