Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 upgrade of go-crypto #182

Merged
merged 116 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
0eb9fa5
Add support for v6 public key and secret key packets
lubux Apr 11, 2023
6199e47
Replace config v5Keys field with config v6Keys field
lubux Mar 24, 2023
fecd413
Add support for v6 signatures
lubux Mar 27, 2023
c0784f9
Add support for direct-key signatures and v6 key messages
lubux Mar 27, 2023
35770b9
Add support for v6 one-pass-signatures and update read/write API
lubux Mar 28, 2023
7ed878a
Remove armor checksums
lubux Mar 29, 2023
b5fb1e3
FIX: Ensure all IVs and salts contain randomness equal to their length
lubux Mar 29, 2023
d1a77a1
FIX: SignatureType constants
lubux Mar 29, 2023
b11525d
Add support for Padding packets
lubux Mar 29, 2023
ff41495
Add support for SKESK v6
lubux Mar 29, 2023
741dddf
Add support for PKESK v6
lubux Mar 29, 2023
ed35ec1
Add support for v6 AEAD private key encryption
lubux Mar 30, 2023
dc99efd
Add support for X25519 and X448 session key encryption
lubux Mar 31, 2023
306ec0d
FIX: KeysByID with direct signatures and correct one pass signature v…
lubux Apr 3, 2023
253d004
Add support for Ed2551 and Ed448 keys and signatures
lubux Apr 3, 2023
2581248
Mandate AES for X25519 and X448 in v3 PKESKs
lubux Apr 6, 2023
f3bce80
Remove S2K secret key encryption type from config
lubux Apr 5, 2023
d0b8f30
Make PrimarySelfSignature public on Entity
lubux Apr 11, 2023
eb368c2
Add Argon2-AEAD encrypted secret key test case
lubux Apr 12, 2023
4147fe2
Add support for v6 signatures in cleartext messages
lubux Apr 13, 2023
c62d973
Implement suggested formatting changes by twiss
lubux Apr 18, 2023
0510848
Implements clearsign message for v6 correctly
lubux Apr 18, 2023
79a381f
Rename PrepareSignWithSalt to SetSalt
lubux Apr 19, 2023
7f0b978
Update clearetext message creation
lubux Apr 20, 2023
848b22f
Add V6 getter method in config
lubux Apr 18, 2023
2141f18
Add missing check for self-signature expiration
lubux Apr 18, 2023
bd16267
Fix naming issues
lubux Apr 18, 2023
26afebe
Augment SerializeEncryptedKey API to ensure backwards compatibility
lubux Apr 18, 2023
7f25dd6
Imitate model for v6 direct key self-signatures from identity self-si…
lubux Apr 19, 2023
a2c729e
Refactor private key as suggested by twiss
lubux Apr 19, 2023
d84a83c
Update PKESK to the latest version of the crypto refresh
lubux Apr 19, 2023
a4e36b0
Run gofmt on project
lubux Apr 19, 2023
3c375b0
Fix one-pass-signature parsing with wrong version
lubux Apr 20, 2023
c92612b
Only check HashTag when sig.Version greater than 4
lubux Apr 21, 2023
51e16b3
Update HKDF in X25519 and X448
lubux Apr 24, 2023
f90e664
Add CRC24 armor footer
lubux Apr 24, 2023
98de8c7
Ensure correct key derivation when encrypting multiple keys with aead
lubux May 5, 2023
3573e94
Add testcase for reading a v6 PKESK encrypted message
lubux May 5, 2023
509d55f
Update PKESKv6 serialization/parsing to the new packet format
lubux May 24, 2023
c1f4c6f
Update one-pass signature v6 packets to latest crypto refresh version
lubux May 24, 2023
1dd6feb
Remove salted hash header from signed cleartext messages
lubux May 30, 2023
21092dc
Copy go-crypto v2 API code to openpgp/v2
lubux Aug 8, 2023
774c082
Add dedicated v2 integration tests
lubux Aug 8, 2023
1d56dee
Merge go-crypto v2 openpgp subpackages changes
lubux Aug 8, 2023
633db87
Update depdency versions
lubux Aug 8, 2023
696c023
Update readme and changelog for v2
lubux Aug 8, 2023
60fa713
feat: Unify write API by offering sign detached with params
lubux Aug 15, 2023
3493ab3
Remove invalid testcase in v2 after rebase
lubux Aug 16, 2023
c695db0
Remove changelog-v2 file
lubux Aug 16, 2023
e884ac0
fix(armor): Remove duplicated test
lubux Aug 16, 2023
f598b26
fix(CI): Update github actions with gopenpgp v3 and gosop v2
lubux Aug 16, 2023
6e3d94b
fix(go1.15): Ensure compatibility with go 1.15
lubux Aug 16, 2023
320232b
fix: Remove testcase that is obsolete after rebase
lubux Aug 16, 2023
608bc7b
fix(CI): Use updated openpgp-interop-test-analyzer
lubux Aug 16, 2023
162f22f
fix(packet): Ensure that packet reader skips marker packets
lubux Aug 17, 2023
d36fda7
feat(CI): Compare v1 and v2 API to the main branch
lubux Aug 17, 2023
3cd52da
fix(packet): Remove argument for backward compatibility
lubux Aug 17, 2023
19c7808
fix(armor): Emit an armor checksum in v1 API
lubux Aug 17, 2023
3e41c8c
ci: Update interop-test to latest version
lubux Aug 17, 2023
48f7095
ci: Update to latest OpenPGP interoperability test suite
lubux Aug 18, 2023
53ffda9
fix(packet): Ensure that unhashed subpackets length is parsed correctly
lubux Aug 31, 2023
3bdcc5b
fix(packet): Do not allocate memory for padding packet
lubux Aug 31, 2023
778b489
fix(packet): Only throw error if the issuer signature subpacket is in…
lubux Aug 31, 2023
4294467
feat(v2): Change message details signature candidate selection for no…
lubux Sep 26, 2023
3443512
ci: Update to latest gopenpgp v3 fot ci interop tests
lubux Sep 27, 2023
9e18830
feat(v2): Allow to include external signatures in messages
lubux Sep 28, 2023
174dc6b
feat(v2): Allow to set the time for selecting keys in encryption
lubux Sep 28, 2023
94d8fd9
feat: Do not allow to generate or use v6 keys with legacy oid
lubux Sep 29, 2023
4c9baeb
fix: Do not allow EdDSA for v6 in integration tests
lubux Oct 2, 2023
d1f7ff4
feat(v2): Refactor entity generation and force hash selection for sig…
lubux Oct 5, 2023
0c44431
feat(v2): Add flag that can disable intended recipient in signcrypt
lubux Oct 12, 2023
4aabb69
fix(armor/clearsign): Address review comments
lubux Nov 22, 2023
820b395
refactor(ed25519): Address review comments
lubux Nov 22, 2023
13e4612
refactor(ed448): Address review comments
lubux Nov 22, 2023
3198ed3
refactor(x25519): Apply review comments and improve readability
lubux Nov 22, 2023
49087ba
refactor(x448): Apply review feedback and improve readability
lubux Nov 22, 2023
3d55a7e
refactor(integration_tests): Re-enable compression and resolve lint w…
lubux Nov 22, 2023
1408255
docs(packet): Improve the docs in packet.Config
lubux Nov 22, 2023
c10c41e
refactor(packet): Integrate changes from review in PKESK
lubux Nov 22, 2023
4863db4
docs(packet): Adapt comment in marker packet implementation
lubux Nov 22, 2023
ddb84e3
fix(packet): Fix pre-check error in public key signature verification
lubux Nov 22, 2023
1dc0808
refactor(packet): Implement feedback for private and pubic key packet
lubux Nov 22, 2023
708c2ad
refactor(packet): Integrate fedback in signature packet logic
lubux Nov 22, 2023
fb84e16
refactor: Do not ignore errors in canonical hasher
lubux Nov 22, 2023
78f1529
refactor(v2): Implement feedback for key operations
lubux Nov 22, 2023
f0a31d2
docs(v2): Improve documentation in pgp message read
lubux Nov 22, 2023
bf37126
ci: Update to refactored gopenpgp v3
lubux Nov 22, 2023
cc1afdc
docs(v2): Add missing docs in subkey implementation
lubux Nov 23, 2023
be8d42d
fix(v2): SHA256 should not be accepted for 384-bit curves
lubux Nov 23, 2023
3db5173
refactor(v2): Integrate suggested changes in the write api
lubux Nov 23, 2023
1ab7fbc
refactor: Change write test errors
lubux Nov 23, 2023
1f9ab12
refactor: StructuralError instead of InvalidArgumentError in write api
lubux Nov 23, 2023
59054bc
refactor: Resolve warnings and suggestions in read/write tests
lubux Nov 23, 2023
dc7272a
docs: Pass on keys and keys test for grammar issues
lubux Nov 23, 2023
d16b56e
fix(packet): x448 and x25519 key parsing ignored error
lubux Nov 23, 2023
efe3451
fix(packet): Signature salt should not be created twice
lubux Nov 23, 2023
bebb8bc
refactor: Pass with linter and check errors
lubux Nov 23, 2023
e94987c
chore: Update gitignore
lubux Nov 23, 2023
26e7edc
docs(packet): Fix grammar issue in config comments
lubux Nov 23, 2023
e3b2b43
refactor(test): Handle errors if possible
lubux Nov 23, 2023
d47e648
docs(v2): Improve documentation in signatures for keys
lubux Nov 24, 2023
8b9879a
docs(keys): Fix self-signature check comments
lubux Nov 27, 2023
8781dd3
docs(v2): Fix comment issues
lubux Nov 27, 2023
f5a3bd6
feat(v2): Allow to encrypt a message to additional passwords
lubux Nov 30, 2023
eafe562
docs(ed448): Fix wrong curve names
lubux Dec 11, 2023
008cc9d
Apply suggestions from code review
lubux Dec 11, 2023
f2990fa
fix(v2): Address review comments in the write api
lubux Dec 11, 2023
ae457d1
docs(v2): Improve comments in the read api
lubux Dec 11, 2023
0a030a3
refactor: Remove depricated tests
lubux Dec 11, 2023
2cc531d
docs(v2): Remove old v1 comment in keys
lubux Dec 11, 2023
9cf78f4
fix(packet): Use constant time copy with secrets
lubux Dec 11, 2023
0b527c6
docs: Unify x448 and x25119 naming in comments and strings
lubux Dec 11, 2023
a09d905
fix: Fix metadata in hash suffix for v5 signatures
lubux Jan 5, 2024
38191b9
fix: Fix literal metadata in hash suffix for v5 signatures
lubux Jan 5, 2024
75630f2
chore: Update min go version and dependencies
lubux Jan 17, 2024
93256de
refactor: Replacer ioutil.ReadAll with io.ReadAll
lubux Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/actions/build-gosop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ inputs:
required: true
default: './gosop-${{ github.sha }}'

branch-gosop:
description: 'Branch of the gosop to use'
required: false
default: 'main'

gosop-build-path:
description: 'Build script of the gosop to use'
required: false
default: 'build_gosop_v1.sh'

runs:
using: "composite"
steps:
Expand All @@ -30,6 +40,7 @@ runs:
uses: actions/checkout@v3
with:
repository: ProtonMail/gosop
ref: ${{ inputs.branch-gosop }}
path: gosop
- name: Cache go modules
uses: actions/cache@v3
Expand All @@ -41,7 +52,7 @@ runs:
restore-keys: |
${{ runner.os }}-go-
- name: Build gosop
run: ./.github/test-suite/build_gosop.sh
run: ./.github/test-suite/${{ inputs.gosop-build-path }}
shell: bash
# Test the binary
- name: Print gosop version
Expand Down
2 changes: 1 addition & 1 deletion .github/test-suite/build_gosop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cd gosop
echo "replace github.com/ProtonMail/go-crypto => ../go-crypto" >> go.mod
go get github.com/ProtonMail/go-crypto
go get github.com/ProtonMail/gopenpgp/v2/crypto@latest
go get github.com/ProtonMail/gopenpgp/v3/crypto@8acccb3915b46d8765d536ff9669bb61ec567f77
go build .
5 changes: 5 additions & 0 deletions .github/test-suite/build_gosop_v1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd gosop
echo "replace github.com/ProtonMail/go-crypto => ../go-crypto" >> go.mod
go get github.com/ProtonMail/go-crypto
go get github.com/ProtonMail/gopenpgp/v2/crypto@latest
go build .
8 changes: 6 additions & 2 deletions .github/test-suite/config.json.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"drivers": [
{
"id": "gosop-branch",
"path": "__GOSOP_BRANCH__"
"id": "gosop-branch-v1",
"path": "__GOSOP_BRANCH_V1__"
},
{
"id": "gosop-branch-v2",
"path": "__GOSOP_BRANCH_V2__"
},
{
"id": "gosop-main",
Expand Down
8 changes: 5 additions & 3 deletions .github/test-suite/prepare_config.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
CONFIG_TEMPLATE=$1
CONFIG_OUTPUT=$2
GOSOP_BRANCH=$3
GOSOP_MAIN=$4
GOSOP_BRANCH_V1=$3
GOSOP_BRANCH_V2=$4
GOSOP_MAIN=$5
cat $CONFIG_TEMPLATE \
| sed "s@__GOSOP_BRANCH__@${GOSOP_BRANCH}@g" \
| sed "s@__GOSOP_BRANCH_V1__@${GOSOP_BRANCH_V1}@g" \
| sed "s@__GOSOP_BRANCH_V2__@${GOSOP_BRANCH_V2}@g" \
| sed "s@__GOSOP_MAIN__@${GOSOP_MAIN}@g" \
| sed "s@__SQOP__@${SQOP}@g" \
| sed "s@__GPGME_SOP__@${GPGME_SOP}@g" \
Expand Down
86 changes: 62 additions & 24 deletions .github/workflows/interop-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,41 @@ on:
branches: [ main ]

jobs:

build-gosop:
name: Build gosop from branch
build-gosop-v1:
name: Build gosop from branch v1-api
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build gosop from branch
uses: ./.github/actions/build-gosop
with:
binary-location: ./gosop-${{ github.sha }}-v1
# Upload as artifact
- name: Upload gosop artifact
uses: actions/upload-artifact@v3
with:
name: gosop-${{ github.sha }}-v1
path: ./gosop-${{ github.sha }}-v1

build-gosop-v2:
name: Build gosop from branch v2-api
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build gosop from branch
uses: ./.github/actions/build-gosop
with:
binary-location: ./gosop-${{ github.sha }}
binary-location: ./gosop-${{ github.sha }}-v2
branch-gosop: gosop-gopenpgp-v3
gosop-build-path: build_gosop.sh
# Upload as artifact
- name: Upload gosop artifact
uses: actions/upload-artifact@v3
with:
name: gosop-${{ github.sha }}
path: ./gosop-${{ github.sha }}
name: gosop-${{ github.sha }}-v2
path: ./gosop-${{ github.sha }}-v2

build-gosop-main:
name: Build gosop from main
Expand All @@ -40,18 +58,18 @@ jobs:
with:
name: gosop-main
path: ./gosop-main


test-suite:
name: Run interoperability test suite
runs-on: ubuntu-latest
container:
image: ghcr.io/protonmail/openpgp-interop-test-docker:v1.1.1
image: ghcr.io/protonmail/openpgp-interop-test-docker:v.1.1.3
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
needs:
- build-gosop
- build-gosop-v1
- build-gosop-v2
- build-gosop-main
steps:
- name: Checkout
Expand All @@ -66,21 +84,33 @@ jobs:
run: chmod +x gosop-main
- name: Print gosop-main version
run: ./gosop-main version --extended
# Fetch gosop from branch
- name: Download gosop-branch
# Fetch gosop from branch v1
- name: Download gosop-branch-v1
uses: actions/download-artifact@v3
with:
name: gosop-${{ github.sha }}-v1
- name: Rename gosop-branch-v1
run: mv gosop-${{ github.sha }}-v1 gosop-branch-v1
# Test gosop-branch v1
- name: Make gosop-branch-v1 executable
run: chmod +x gosop-branch-v1
- name: Print gosop-branch-v1 version
run: ./gosop-branch-v1 version --extended
# Fetch gosop from branch v2
- name: Download gosop-branch-v2
uses: actions/download-artifact@v3
with:
name: gosop-${{ github.sha }}
- name: Rename gosop-branch
run: mv gosop-${{ github.sha }} gosop-branch
# Test gosop-branch
- name: Make gosop-branch executable
run: chmod +x gosop-branch
- name: Print gosop-branch version
run: ./gosop-branch version --extended
name: gosop-${{ github.sha }}-v2
- name: Rename gosop-branch-v2
run: mv gosop-${{ github.sha }}-v2 gosop-branch-v2
# Test gosop-branch v2
- name: Make gosop-branch-v2 executable
run: chmod +x gosop-branch-v2
- name: Print gosop-branch-v2 version
run: ./gosop-branch-v2 version --extended
# Run test suite
- name: Prepare test configuration
run: ./.github/test-suite/prepare_config.sh $CONFIG_TEMPLATE $CONFIG_OUTPUT $GITHUB_WORKSPACE/gosop-branch $GITHUB_WORKSPACE/gosop-main
run: ./.github/test-suite/prepare_config.sh $CONFIG_TEMPLATE $CONFIG_OUTPUT $GITHUB_WORKSPACE/gosop-branch-v1 $GITHUB_WORKSPACE/gosop-branch-v2 $GITHUB_WORKSPACE/gosop-main
env:
CONFIG_TEMPLATE: .github/test-suite/config.json.template
CONFIG_OUTPUT: .github/test-suite/config.json
Expand Down Expand Up @@ -116,10 +146,18 @@ jobs:
uses: actions/download-artifact@v3
with:
name: test-suite-results.json
- name: Compare with baseline
uses: ProtonMail/openpgp-interop-test-analyzer@v1
- name: Compare with baseline v1
uses: ProtonMail/openpgp-interop-test-analyzer@5d7f4b6868ebe3bfc909302828342c461f5f4940
with:
results: ${{ steps.download-test-results.outputs.download-path }}/test-suite-results.json
output: baseline-comparison.json
output: baseline-comparison-v1.json
baseline: gosop-main
target: gosop-branch
target: gosop-branch-v1
- name: Compare with baseline v2
uses: ProtonMail/openpgp-interop-test-analyzer@5d7f4b6868ebe3bfc909302828342c461f5f4940
with:
results: ${{ steps.download-test-results.outputs.download-path }}/test-suite-results.json
output: baseline-comparison-v2.json
baseline: gosop-main
target: gosop-branch-v2

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Add no patterns to .gitignore except for files generated by the build.
last-change
.idea
.idea
settings.json
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ so you can simply replace all imports of `golang.org/x/crypto/openpgp` with
`github.com/ProtonMail/go-crypto/openpgp`.

A partial list of changes is here: https://github.com/ProtonMail/go-crypto/issues/21#issuecomment-492792917.

For the more extended API for reading and writing OpenPGP messages use `github.com/ProtonMail/go-crypto/openpgp/v2`, but it is not fully backwards compatible with `golang.org/x/crypto/openpgp`.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.13

require (
github.com/cloudflare/circl v1.3.3
golang.org/x/crypto v0.7.0
golang.org/x/crypto v0.9.0
)
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -26,19 +26,19 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down
5 changes: 3 additions & 2 deletions ocb/ocb.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"crypto/cipher"
"crypto/subtle"
"errors"
"github.com/ProtonMail/go-crypto/internal/byteutil"
"math/bits"

"github.com/ProtonMail/go-crypto/internal/byteutil"
)

type ocb struct {
Expand Down Expand Up @@ -153,7 +154,7 @@ func (o *ocb) crypt(instruction int, Y, nonce, adata, X []byte) []byte {
truncatedNonce := make([]byte, len(nonce))
copy(truncatedNonce, nonce)
truncatedNonce[len(truncatedNonce)-1] &= 192
Ktop := make([]byte, blockSize)
var Ktop []byte
if bytes.Equal(truncatedNonce, o.reusableKtop.noncePrefix) {
Ktop = o.reusableKtop.Ktop
} else {
Expand Down
Loading