Refactor setup
This commit is contained in:
parent
94b317f135
commit
0456595f68
25 changed files with 37 additions and 33 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
.DS_Store
|
||||
bin
|
||||
pkg
|
||||
vendor
|
||||
.vscode
|
||||
.vscode
|
||||
|
|
|
|||
9
build.sh
9
build.sh
|
|
@ -7,18 +7,23 @@ ANDROID_OUT=${OUTPUT_PATH}/"Android"
|
|||
IOS_OUT=${OUTPUT_PATH}/"iOS"
|
||||
mkdir -p $ANDROID_OUT
|
||||
mkdir -p $IOS_OUT
|
||||
|
||||
ln -s . vendor/src
|
||||
|
||||
# CHECK="${1-0}"
|
||||
# if [ ${CHECK} -eq "1" ]; then
|
||||
printf "\e[0;32mStart Building iOS framework .. Location: ${IOS_OUT} \033[0m\n\n"
|
||||
|
||||
gomobile bind -target ios -o ${IOS_OUT}/pmcrypto.framework proton/pmcrypto/crypto proton/pmcrypto/armor proton/pmcrypto/constants proton/pmcrypto/key proton/pmcrypto/models
|
||||
GOPATH="$SCRIPT_LOCATION:$SCRIPT_LOCATION/vendor:$GOPATH" gomobile bind -target ios -o ${IOS_OUT}/pmcrypto.framework gitlab.com/ProtonMail/go-pm-crypto/crypto gitlab.com/ProtonMail/go-pm-crypto/armor gitlab.com/ProtonMail/go-pm-crypto/constants gitlab.com/ProtonMail/go-pm-crypto/key gitlab.com/ProtonMail/go-pm-crypto/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
|
||||
GOPATH="$SCRIPT_LOCATION:$SCRIPT_LOCATION/vendor:$GOPATH" gomobile bind -target android -javapkg com.proton.pmcrypto -o ${ANDROID_OUT}/pmcrypto.aar gitlab.com/ProtonMail/go-pm-crypto/crypto gitlab.com/ProtonMail/go-pm-crypto/armor gitlab.com/ProtonMail/go-pm-crypto/constants gitlab.com/ProtonMail/go-pm-crypto/key gitlab.com/ProtonMail/go-pm-crypto/models
|
||||
|
||||
printf "\e[0;32mInstalling frameworks. \033[0m\n\n"
|
||||
|
||||
unlink vendor/src
|
||||
|
||||
printf "\e[0;32mAll Done. \033[0m\n\n"
|
||||
|
||||
|
||||
|
|
|
|||
BIN
dist/Android/pmcrypto-sources.jar
vendored
BIN
dist/Android/pmcrypto-sources.jar
vendored
Binary file not shown.
BIN
dist/Android/pmcrypto.aar
vendored
BIN
dist/Android/pmcrypto.aar
vendored
Binary file not shown.
14
glide.lock
generated
14
glide.lock
generated
|
|
@ -1,8 +1,10 @@
|
|||
hash: 0e0069ce69a4e3bde6233726f21a880347400808a97c2e6f7a173e4d7daea51c
|
||||
updated: 2018-09-07T10:20:50.211694+02:00
|
||||
hash: 7169f4883725d9716bbd62ecee1f32d73e8529b4bb0989173826e986395afe6b
|
||||
updated: 2018-10-24T18:02:15.233807+02:00
|
||||
imports:
|
||||
- name: github.com/konsorten/go-windows-terminal-sequences
|
||||
version: 5c8c8bd35d3832f5d134ae1e1e375b69a4d25242
|
||||
- name: github.com/Sirupsen/logrus
|
||||
version: 3791101e143bf0f32515ac23e831475684f61229
|
||||
version: 4fabf2fffcecfd47f802869b7b92d75e43c5a095
|
||||
- name: golang.org/x/crypto
|
||||
version: 9e4251120d8c43f10024d798bc6dde21d40704a0
|
||||
repo: https://github.com/ProtonMail/crypto.git
|
||||
|
|
@ -31,12 +33,12 @@ imports:
|
|||
- rsa
|
||||
- ssh/terminal
|
||||
- name: golang.org/x/sys
|
||||
version: 8cf3aee429924738c56c34bb819c4ea8273fc434
|
||||
version: 5cd93ef61a7c8f0f858690154eb6de2e69415fa1
|
||||
subpackages:
|
||||
- unix
|
||||
- windows
|
||||
- name: golang.org/x/text
|
||||
version: 4ae1256249243a4eb350a9a372e126557f2aa346
|
||||
version: 4d1c5fb19474adfe9562c9847ba425e7da817e81
|
||||
subpackages:
|
||||
- encoding
|
||||
- encoding/charmap
|
||||
|
|
@ -44,6 +46,6 @@ imports:
|
|||
- encoding/internal/identifier
|
||||
- transform
|
||||
- name: proton/pmmime
|
||||
version: 347d69204aa62d6958bcb3b9bbacccb24a36372b
|
||||
version: 72b7b1bf2d1b491e1d003632a0fda41410b0bb59
|
||||
repo: git@gitlab.protontech.ch:ProtonMail/go-pm-mime.git
|
||||
testImports: []
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package: proton/pmcrypto
|
||||
package: gitlab.com/ProtonMail/go-pm-crypto
|
||||
import:
|
||||
- package: golang.org/x/crypto
|
||||
version: v1.0.0
|
||||
|
|
|
|||
3
init.sh
Executable file
3
init.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
GOPATH="$DIR" glide up
|
||||
GOPATH="$DIR:$DIR/vendor:$GOPATH" gomobile init -ndk $ANDROID_NDK
|
||||
|
|
@ -8,9 +8,9 @@ import (
|
|||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
armorUtils "proton/pmcrypto/armor"
|
||||
"proton/pmcrypto/internal"
|
||||
"proton/pmcrypto/models"
|
||||
armorUtils "gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/internal"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/models"
|
||||
)
|
||||
|
||||
//EncryptAttachmentBinKey ...
|
||||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"math/big"
|
||||
"proton/pmcrypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -13,9 +13,9 @@ import (
|
|||
errors2 "golang.org/x/crypto/openpgp/errors"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"math"
|
||||
armorUtils "proton/pmcrypto/armor"
|
||||
"proton/pmcrypto/internal"
|
||||
"proton/pmcrypto/models"
|
||||
armorUtils "gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/internal"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/models"
|
||||
)
|
||||
|
||||
// DecryptMessage decrypt encrypted message use private key (string )
|
||||
|
|
@ -9,8 +9,7 @@ import (
|
|||
"io/ioutil"
|
||||
"bytes"
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"proton/pmcrypto/armor"
|
||||
)
|
||||
)
|
||||
|
||||
// ======================== Attachments Collector ==============
|
||||
// Collect contents of all attachment parts and return
|
||||
|
|
@ -34,7 +33,6 @@ func (pm PmCrypto) parseMIME(mimeBody string, verifierKey []byte) (*pmmime.BodyC
|
|||
bodyCollector := pmmime.NewBodyCollector(printAccepter)
|
||||
attachmentsCollector := pmmime.NewAttachmentsCollector(bodyCollector)
|
||||
mimeVisitor := pmmime.NewMimeVisitor(attachmentsCollector)
|
||||
str, err := armor.ArmorKey(verifierKey)
|
||||
signatureCollector := newSignatureCollector(mimeVisitor, pubKeyEntries, config)
|
||||
err = pmmime.VisitAll(bytes.NewReader(mmBodyData), h, signatureCollector)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package crypto
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"proton/pmcrypto/internal"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/internal"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"proton/pmcrypto/armor"
|
||||
"proton/pmcrypto/models"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/models"
|
||||
)
|
||||
|
||||
//RandomToken ...
|
||||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"golang.org/x/crypto/openpgp/packet"
|
||||
errors2 "golang.org/x/crypto/openpgp/errors"
|
||||
"io"
|
||||
"proton/pmcrypto/internal"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/internal"
|
||||
)
|
||||
|
||||
// SignTextDetached sign detached text type
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
package crypto
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"net/textproto"
|
||||
"proton/pmmime"
|
||||
)
|
||||
|
|
@ -7,7 +7,6 @@ import (
|
|||
// UpdateTime update cached time
|
||||
func (pm *PmCrypto) UpdateTime(newTime int64) {
|
||||
pm.latestServerTime = newTime
|
||||
pm.latestClientTime = time.Now()
|
||||
}
|
||||
|
||||
//GetTime get latest cached time
|
||||
|
|
@ -16,10 +15,8 @@ func (pm *PmCrypto) GetTime() int64 {
|
|||
}
|
||||
|
||||
func (pm *PmCrypto) getNow() time.Time {
|
||||
if pm.latestServerTime > 0 && !pm.latestClientTime.IsZero() {
|
||||
// Sub is monotome, it uses a monotime time clock in this case instead of the wall clock
|
||||
extrapolate := int64(pm.latestClientTime.Sub(time.Now()).Seconds())
|
||||
return time.Unix(pm.latestServerTime + extrapolate, 0)
|
||||
if pm.latestServerTime > 0 {
|
||||
return time.Unix(pm.latestServerTime, 0)
|
||||
}
|
||||
|
||||
return time.Now()
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"errors"
|
||||
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"proton/pmcrypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
)
|
||||
|
||||
// GetFingerprint get a armored public key fingerprint
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
"bytes"
|
||||
"proton/pmcrypto/armor"
|
||||
"gitlab.com/ProtonMail/go-pm-crypto/armor"
|
||||
)
|
||||
|
||||
//CheckPassphrase check is private key passphrase ok
|
||||
Loading…
Add table
Add a link
Reference in a new issue