diff --git a/.gitignore b/.gitignore index 99b3bbb..c0b49e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store bin +dist vendor -.vscode \ No newline at end of file +.vscode diff --git a/armor/armor.go b/armor/armor.go index 678f0dd..50df2b7 100644 --- a/armor/armor.go +++ b/armor/armor.go @@ -3,8 +3,8 @@ package armor import ( "bytes" "errors" - "gitlab.com/ProtonMail/go-pm-crypto/internal" - "gitlab.com/ProtonMail/go-pm-crypto/models" + "github.com/ProtonMail/go-pm-crypto/internal" + "github.com/ProtonMail/go-pm-crypto/models" "golang.org/x/crypto/openpgp/armor" "golang.org/x/crypto/openpgp/clearsign" "golang.org/x/crypto/openpgp/packet" diff --git a/armor/constants.go b/armor/constants.go index 191d19b..483fe9f 100644 --- a/armor/constants.go +++ b/armor/constants.go @@ -1,7 +1,7 @@ package armor import ( - "gitlab.com/ProtonMail/go-pm-crypto/internal" + "github.com/ProtonMail/go-pm-crypto/internal" ) const ( diff --git a/build.sh b/build.sh index ae2de9f..6f73f25 100755 --- a/build.sh +++ b/build.sh @@ -10,12 +10,13 @@ mkdir -p $IOS_OUT # CHECK="${1-0}" # if [ ${CHECK} -eq "1" ]; then printf "\e[0;32mStart Building iOS framework .. Location: ${IOS_OUT} \033[0m\n\n" +PACKAGE_PATH=github.com/ProtonMail/go-pm-crypto -gomobile bind -target ios -o ${IOS_OUT}/pmcrypto.framework proton/pmcrypto/crypto proton/pmcrypto/armor proton/pmcrypto/constants proton/pmcrypto/key proton/pmcrypto/models +gomobile bind -target ios -o ${IOS_OUT}/pmcrypto.framework $PACKAGE_PATH/crypto $PACKAGE_PATH/armor $PACKAGE_PATH/constants $PACKAGE_PATH/key $PACKAGE_PATH/models printf "\e[0;32mStart Building Android lib .. Location: ${ANDROID_OUT} \033[0m\n\n" -gomobile bind -target android -javapkg com.proton.pmcrypto -o ${ANDROID_OUT}/pmcrypto.aar proton/pmcrypto/crypto proton/pmcrypto/armor proton/pmcrypto/constants proton/pmcrypto/key proton/pmcrypto/models +gomobile bind -target android -javapkg com.proton.pmcrypto -o ${ANDROID_OUT}/pmcrypto.aar $PACKAGE_PATH/crypto $PACKAGE_PATH/armor $PACKAGE_PATH/constants $PACKAGE_PATH/key $PACKAGE_PATH/models printf "\e[0;32mInstalling frameworks. \033[0m\n\n" diff --git a/crypto/attachment.go b/crypto/attachment.go index 16cfcb9..8fe23d6 100644 --- a/crypto/attachment.go +++ b/crypto/attachment.go @@ -5,9 +5,9 @@ import ( "io" "io/ioutil" - armorUtils "gitlab.com/ProtonMail/go-pm-crypto/armor" - "gitlab.com/ProtonMail/go-pm-crypto/internal" - "gitlab.com/ProtonMail/go-pm-crypto/models" + armorUtils "github.com/ProtonMail/go-pm-crypto/armor" + "github.com/ProtonMail/go-pm-crypto/internal" + "github.com/ProtonMail/go-pm-crypto/models" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" "golang.org/x/crypto/openpgp/packet" diff --git a/crypto/key.go b/crypto/key.go index 0588d21..9a93524 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "gitlab.com/ProtonMail/go-pm-crypto/armor" + "github.com/ProtonMail/go-pm-crypto/armor" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/packet" "math/big" diff --git a/crypto/message.go b/crypto/message.go index 5c81453..304033d 100644 --- a/crypto/message.go +++ b/crypto/message.go @@ -8,9 +8,9 @@ import ( "strings" "time" - armorUtils "gitlab.com/ProtonMail/go-pm-crypto/armor" - "gitlab.com/ProtonMail/go-pm-crypto/internal" - "gitlab.com/ProtonMail/go-pm-crypto/models" + armorUtils "github.com/ProtonMail/go-pm-crypto/armor" + "github.com/ProtonMail/go-pm-crypto/internal" + "github.com/ProtonMail/go-pm-crypto/models" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" errors2 "golang.org/x/crypto/openpgp/errors" diff --git a/crypto/mime.go b/crypto/mime.go index ad4bbf7..a22b88e 100644 --- a/crypto/mime.go +++ b/crypto/mime.go @@ -2,8 +2,8 @@ package crypto import ( "bytes" + "github.com/ProtonMail/go-pm-crypto/armor" "github.com/ProtonMail/go-pm-mime" - "gitlab.com/ProtonMail/go-pm-crypto/armor" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/packet" "io/ioutil" diff --git a/crypto/session.go b/crypto/session.go index aece9e7..7b0aa04 100644 --- a/crypto/session.go +++ b/crypto/session.go @@ -7,8 +7,8 @@ import ( "io" "strings" - "gitlab.com/ProtonMail/go-pm-crypto/armor" - "gitlab.com/ProtonMail/go-pm-crypto/models" + "github.com/ProtonMail/go-pm-crypto/armor" + "github.com/ProtonMail/go-pm-crypto/models" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/packet" ) diff --git a/crypto/sign_detached.go b/crypto/sign_detached.go index 0edd489..b940e3d 100644 --- a/crypto/sign_detached.go +++ b/crypto/sign_detached.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "gitlab.com/ProtonMail/go-pm-crypto/internal" + "github.com/ProtonMail/go-pm-crypto/internal" "golang.org/x/crypto/openpgp" errors2 "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/packet" diff --git a/dist/Android/pmcrypto-sources.jar b/dist/Android/pmcrypto-sources.jar index 1787558..9131e32 100644 Binary files a/dist/Android/pmcrypto-sources.jar and b/dist/Android/pmcrypto-sources.jar differ diff --git a/dist/Android/pmcrypto.aar b/dist/Android/pmcrypto.aar index f4d33e2..1a23da8 100644 Binary files a/dist/Android/pmcrypto.aar and b/dist/Android/pmcrypto.aar differ diff --git a/glide.lock b/glide.lock index 428a4b2..0d7b32a 100644 --- a/glide.lock +++ b/glide.lock @@ -31,7 +31,6 @@ imports: - rsa - ssh/terminal - name: golang.org/x/sys - version: 8cf3aee429924738c56c34bb819c4ea8273fc434 subpackages: - unix - windows @@ -43,7 +42,8 @@ imports: - encoding/internal - encoding/internal/identifier - transform -- name: proton/pmmime +- name: github.com/ProtonMail/go-pm-mime version: 347d69204aa62d6958bcb3b9bbacccb24a36372b - repo: git@gitlab.protontech.ch:ProtonMail/go-pm-mime.git + repo: https://gitlab.protontech.ch/ProtonMail/go-pm-mime.git + version: feat/mimevisitor testImports: [] diff --git a/glide.yaml b/glide.yaml index d62c93c..47d3ae4 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,7 +1,9 @@ package: proton/pmcrypto import: - package: golang.org/x/crypto - version: v1.0.0 + version: master repo: https://github.com/ProtonMail/crypto.git -- package: proton/pmmime - repo: git@gitlab.protontech.ch:ProtonMail/go-pm-mime.git + version: 9e4251120d8c43f10024d798bc6dde21d40704a0 +- package: github.com/ProtonMail/go-pm-mime + repo: https://gitlab.protontech.ch/ProtonMail/go-pm-mime.git + diff --git a/internal/common.go b/internal/common.go index b949f1e..8116082 100644 --- a/internal/common.go +++ b/internal/common.go @@ -1,7 +1,7 @@ package internal import ( - "gitlab.com/ProtonMail/go-pm-crypto/constants" + "github.com/ProtonMail/go-pm-crypto/constants" "regexp" ) diff --git a/key/fingerprint.go b/key/fingerprint.go index 08394c3..c7fb1ef 100644 --- a/key/fingerprint.go +++ b/key/fingerprint.go @@ -5,8 +5,8 @@ import ( "encoding/hex" "errors" + "github.com/ProtonMail/go-pm-crypto/armor" "golang.org/x/crypto/openpgp" - "proton/pmcrypto/armor" ) // GetFingerprint get a armored public key fingerprint diff --git a/key/key.go b/key/key.go index b54f83e..e805be6 100644 --- a/key/key.go +++ b/key/key.go @@ -1,12 +1,12 @@ package key import ( - "strings" - "golang.org/x/crypto/openpgp" - "fmt" - "golang.org/x/crypto/openpgp/packet" "bytes" - "proton/pmcrypto/armor" + "fmt" + "github.com/ProtonMail/go-pm-crypto/armor" + "golang.org/x/crypto/openpgp" + "golang.org/x/crypto/openpgp/packet" + "strings" ) //CheckPassphrase check is private key passphrase ok @@ -39,7 +39,6 @@ func CheckPassphrase(privateKey string, passphrase string) bool { return true } - // PublicKey get a public key from a private key func PublicKey(privateKey string) (string, error) { privKeyReader := strings.NewReader(privateKey) diff --git a/pmapi/key.go b/pmapi/key.go index 783f3e6..64ced80 100644 --- a/pmapi/key.go +++ b/pmapi/key.go @@ -11,7 +11,7 @@ import ( // "net/url" "strings" - //"gitlab.com/ProtonMail/go-pm-crypto/armor" + //"github.com/ProtonMail/go-pm-crypto/armor" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/packet" ) diff --git a/pmapi/keyring.go b/pmapi/keyring.go index 4980eea..2fb7607 100644 --- a/pmapi/keyring.go +++ b/pmapi/keyring.go @@ -12,16 +12,14 @@ import ( "time" "golang.org/x/crypto/openpgp" - "golang.org/x/crypto/openpgp/armor" + //"golang.org/x/crypto/openpgp/armor" pgperrors "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/packet" - "gitlab.com/ProtonMail/go-pm-crypto/crypto" + armorUtils "github.com/ProtonMail/go-pm-crypto/armor" + "github.com/ProtonMail/go-pm-crypto/crypto" ) -// Armored type for PGP encrypted messages. -const pgpMessageType = "PGP MESSAGE" - // A keypair contains a private key and a public key. type pmKeyObject struct { ID string @@ -188,7 +186,7 @@ func (w *armorEncryptWriter) Close() (err error) { // EncryptArmored encrypts and armors data to the keyring's owner. func (kr *KeyRing) EncryptArmored(w io.Writer, sign *KeyRing) (wc io.WriteCloser, err error) { - aw, err := armor.Encode(w, pgpMessageType, nil) + aw, err := armorUtils.ArmorWithTypeBuffered(w, armorUtils.MESSAGE_HEADER) if err != nil { return } @@ -367,7 +365,7 @@ func (kr *KeyRing) DecryptArmored(r io.Reader) (decrypted io.Reader, signed *Sig return } - if block.Type != pgpMessageType { + if block.Type != armorUtils.MESSAGE_HEADER { err = errors.New("pmapi: not an armored PGP message") return }