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

all: merge upstream changes #11

Merged
merged 114 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
ae2d966
ocsp: add Response.Raw
rolandshoemaker Mar 2, 2022
5352b09
acme/autocert: support External Account Binding (EAB) tokens
benburkert Oct 6, 2021
7b82a4e
all: gofmt
rsc Apr 11, 2022
eb4f295
internal/wycheproof: add ECDH tests, including point decompression
FiloSottile Mar 27, 2022
2cf3ade
internal/wycheproof: skip truncated SHA-512 RSAPSS tests for boring
rolandshoemaker May 6, 2022
c6db032
acme/autocert/internal/acmetest: don't validate in goroutine
rolandshoemaker May 11, 2022
4661260
ssh/agent: fix non-RSA certificates
FiloSottile May 6, 2022
403b017
acme: add AccountKeyRollover
jason-baker May 13, 2022
85d78b3
curve25519/internal/field: update generator to avo v0.4.0
tklauser Mar 1, 2022
6f7dac9
acme: DeactivateReg fix panic
jason-baker May 17, 2022
793ad66
acme/autocert: properly clean DirCache paths
rolandshoemaker May 25, 2022
0559593
curve25519: remove dependency on fmt
aaqaishtyaq Sep 7, 2021
630584e
A+C: delete AUTHORS and CONTRIBUTORS
rsc Jul 22, 2022
04dced1
internal/subtle: rename to internal/alias
rsc Aug 16, 2022
bc19a97
acme: gofmt code with Go 1.19 gofmt
rsc Aug 16, 2022
5757bc0
cryptobyte: add ReadUint64 and AddUint64
hopehook Aug 3, 2022
bd7e27e
ssh/agent: match OpenSSH extensionAgentMsg, not IETF draft
edef1c Jun 14, 2022
c86fa9a
internal/wycheproof: add crypto/ecdh tests
rolandshoemaker Aug 16, 2022
35f4265
all: replace io/ioutil with io and os package
cuishuang Sep 16, 2022
4ba4fb4
acme/autocert: fix renewal timer issue
rolandshoemaker Sep 23, 2022
eccd636
acme/autocert: remove TestRenewFromCache skips
rolandshoemaker Sep 24, 2022
4161e89
all: replace bytes.Compare with bytes.Equal
cuishuang Oct 4, 2022
d6f0a8c
ssh: add ServerConfig.NoClientAuthCallback
bradfitz Mar 23, 2022
9be5aaa
all: fix a few function names on comments
cuishuang Oct 11, 2022
56aed06
all: use automatic RFC linking
Merovius Oct 11, 2022
642fcc3
go.mod: update golang.org/x dependencies
gopherbot Oct 19, 2022
a3485e1
all: use math/bits.RotateLeft
AlexanderYastrebov Oct 24, 2022
334521b
ssh: fix typo
ideapark Nov 3, 2022
183a9b7
go.mod: update golang.org/x dependencies
gopherbot Nov 8, 2022
21d60a1
all: remove redundant type conversion
cuishuang Sep 7, 2022
6fad3df
ssh: support rsa-sha2-256/512 on the server side
FiloSottile Nov 3, 2022
0ec7e83
internal/wycheproof: update Go 1.20 crypto/ecdh API
FiloSottile Nov 16, 2022
2c47667
cryptobyte: add support for ReadASN1Integer into []byte
FiloSottile Nov 17, 2022
eb2c406
go.mod: update golang.org/x dependencies
gopherbot Dec 6, 2022
f495dc3
acme: eliminate arbitrary timeouts in tests
Dec 8, 2022
23edec0
ssh: ensure that handshakeTransport goroutines have finished before C…
Dec 12, 2022
7e3ac20
internal/wycheproof: also use Verify in TestECDSA
rolandshoemaker Nov 28, 2022
bc7d1d1
bcrypt: reject passwords longer than 72 bytes
rolandshoemaker Nov 14, 2022
3d872d0
go.mod: update golang.org/x dependencies
gopherbot Jan 4, 2023
59ff472
all: fix some comments
cuishuang Jan 29, 2023
310bfa4
cryptobyte: reject negative Unwrite argument
AlexanderYastrebov Feb 1, 2023
a9f661c
go.mod: update golang.org/x dependencies
gopherbot Feb 8, 2023
ebe9262
ssh: add support for [email protected]
drakkan Feb 15, 2023
776e461
go.mod: update golang.org/x dependencies
gopherbot Mar 5, 2023
c6a20f9
ssh: document that ParseRawPrivateKey supports Ed25519 keys
nhooyr Jan 24, 2023
9cd0187
curve25519: use crypto/ecdh on Go 1.20
FiloSottile Nov 16, 2022
018c28f
all: fix some comments
cuishuang Mar 20, 2023
00fd4ff
go.mod: update golang.org/x dependencies
gopherbot Apr 6, 2023
1faeef9
cryptobyte: reject Object Identifiers with leading 0x80
mateusz834 Apr 12, 2023
7d6d3f5
ssh/test: skip TestValidTerminalMode on non-Bourne shells
Apr 17, 2023
a8cc953
ssh: skip unsupported tests on wasip1
tklauser Apr 18, 2023
3ef8056
ssh/test: enable on solaris
tklauser Apr 28, 2023
a4e9841
go.mod: update golang.org/x dependencies
gopherbot May 8, 2023
1622238
Add support for "[email protected]"
s-k2 Apr 2, 2020
d0b3160
x509roots: add new module
rolandshoemaker Jan 13, 2023
22c9997
go.mod: tell x repo tagging to ignore dep on net
heschi Jun 12, 2023
8e447d8
go.mod: update golang.org/x dependencies
gopherbot Jun 12, 2023
0ff6005
ssh/test: set a timeout and WaitDelay on sshd subcommands
May 22, 2023
0d502d7
x509roots: use "generate" build tag
rolandshoemaker Jun 20, 2023
043e94c
x509roots: fix generate script argument checking
rolandshoemaker Jun 20, 2023
5fe8145
x509roots: remove list hash and generation date, change ordering
rolandshoemaker Jun 20, 2023
64c3993
ssh: add hmac-sha2-512
stanhu Jun 7, 2023
a9e447d
x509roots/fallback: add //go:build go1.20 to bundle.go
dmitshur Jun 22, 2023
183630a
x509roots: generate a stable sort, for real this time
rolandshoemaker Jun 23, 2023
e984872
go.mod: update golang.org/x dependencies
gopherbot Jul 5, 2023
23b1b90
ssh: prefer sha256 based MAC algorithms
drakkan Jul 1, 2023
64e0e99
ssh: fix RSA certificate and public key authentication with older cli…
drakkan Jun 28, 2023
2e82bdd
fix TestValidTerminalMode: missing output from echo SHELL $SHELL
tg123 Jul 6, 2023
5df3b59
ssh: disable client agent tests on Windows
drakkan Jul 12, 2023
3f8f064
ssh: prefer sha256 based RSA key algorithms
drakkan Jul 1, 2023
12e1fcd
internal/wycheproof: skip all tests in short test mode
dmitshur Jul 18, 2023
d08e19b
x509roots/fallback: update bundle
gopherbot Jul 24, 2023
ddfa821
ssh: ignore invalid MACs and KEXs just like we do for ciphers
drakkan Jul 22, 2023
eab9315
ssh: add diffie-hellman-group16-sha512 kex
drakkan Jun 28, 2023
edc325d
ssh: fix call to Fatalf from a non-test goroutine
drakkan Jul 29, 2023
b4ddeed
go.mod: update golang.org/x dependencies
gopherbot Aug 4, 2023
0d375be
go.mod: update golang.org/x dependencies
gopherbot Sep 3, 2023
c5370d2
ssh: check the declared public key algo against decoded one
drakkan Jun 28, 2023
d359caa
ssh: support for marshaling keys using the OpenSSH format
maraino Feb 8, 2020
e90f1e1
cryptobyte: add uint48 methods
hasheddan Sep 6, 2023
3f0842a
sha3: have ShakeHash extend hash.Hash
mdempsky Sep 10, 2023
28c53ff
ssh: add MultiAlgorithmSigner
drakkan Jul 8, 2023
a1aeb9b
ssh: add test cases for compatibility with old (buggy) clients
drakkan Sep 5, 2023
b665ba6
all: use crypto/ed25519 instead of golang.org/x/crypto/ed25519
thaJeztah Sep 25, 2023
ec07f4e
chacha20: drop Go 1.10 compatibility for arm64
thaJeztah Nov 6, 2022
833695f
ssh: add server side support for [email protected] protocol extension
drakkan Aug 31, 2023
e3cc52e
go.mod: update golang.org/x dependencies
gopherbot Oct 5, 2023
2aeefc3
ssh: add support for SSH_AGENT_CONSTRAIN_EXTENSION with id 255
drakkan Sep 3, 2023
8779cbd
all: update go directive to 1.18
dmitshur Oct 10, 2023
1d57292
x509roots: check HTTP response status code and media type
dmitshur Oct 20, 2023
4f30245
x509roots: catch the zero-roots case when generating the bundle
rolandshoemaker Oct 18, 2023
cf8dcb0
ssh: add test case against ssh CLI
drakkan Jun 28, 2023
74c2ba9
crypto/hkdf: remove useless call to Reset
ericlagergren Aug 12, 2022
df0bc9e
chacha20poly1305: guard PSHUFB usage with GOAMD64_v2
mauri870 Nov 7, 2023
e668aa9
go.mod: update golang.org/x dependencies
gopherbot Nov 8, 2023
42c83ff
ssh: try harder to detect incorrect passwords for legacy PEM encryption
drakkan Oct 31, 2023
eb61739
ssh: allow to configure public key auth algorithms on the server side
drakkan Jul 18, 2023
ff15cd5
ssh: eliminate some goroutine leaks in tests and examples
Nov 9, 2023
a2edfb5
cryptobyte: fix ReadOptionalASN1Boolean
rolandshoemaker Nov 9, 2023
1cf1811
ssh: use the correct token from the client
bodgit Jan 25, 2021
270bf25
curve25519/internal/field/_asm: go mod tidy to fix x/sys version
thaJeztah Nov 9, 2023
1c17e20
ssh: fix certificate authentication with OpenSSH 7.2-7.7
drakkan Jul 16, 2023
b2d7c26
ssh: add (*Client).DialContext method
ydnar Jun 22, 2023
1eadac5
go.mod: update golang.org/x dependencies
gopherbot Nov 27, 2023
325b735
ssh/test: skip TestSSHCLIAuth on Windows
heschi Nov 27, 2023
bda2f3f
argon2: avoid clobbering BP
egonelbre Jul 1, 2021
7e6fbd8
ssh: wrap errors from client handshake
paxan Nov 27, 2023
b8ffc16
blake2b: drop Go 1.6, Go 1.8 compatibility
thaJeztah Nov 9, 2023
fdfe1f8
ssh: defer channel window adjustment
Dec 16, 2022
152cdb1
x509roots/fallback: update bundle
gopherbot Nov 20, 2023
4e5a261
ssh: close net.Conn on all NewServerConn errors
espadolini Dec 12, 2023
9d2ee97
ssh: implement strict KEX protocol changes
rolandshoemaker Nov 20, 2023
08396bb
internal/poly1305: drop Go 1.12 compatibility
thaJeztah Nov 27, 2023
0355684
Merge remote-tracking branch 'upstream/master' into awly/update-latest
awly Jan 3, 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
1 change: 0 additions & 1 deletion acme/version_go112.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build go1.12
// +build go1.12

package acme

Expand Down
1 change: 0 additions & 1 deletion argon2/blamka_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build amd64 && gc && !purego
// +build amd64,gc,!purego

package argon2

Expand Down
13 changes: 6 additions & 7 deletions argon2/blamka_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build amd64 && gc && !purego
// +build amd64,gc,!purego

#include "textflag.h"

Expand Down Expand Up @@ -200,8 +199,8 @@ TEXT ·mixBlocksSSE2(SB), 4, $0-32
MOVQ out+0(FP), DX
MOVQ a+8(FP), AX
MOVQ b+16(FP), BX
MOVQ a+24(FP), CX
MOVQ $128, BP
MOVQ c+24(FP), CX
MOVQ $128, DI

loop:
MOVOU 0(AX), X0
Expand All @@ -214,7 +213,7 @@ loop:
ADDQ $16, BX
ADDQ $16, CX
ADDQ $16, DX
SUBQ $2, BP
SUBQ $2, DI
JA loop
RET

Expand All @@ -223,8 +222,8 @@ TEXT ·xorBlocksSSE2(SB), 4, $0-32
MOVQ out+0(FP), DX
MOVQ a+8(FP), AX
MOVQ b+16(FP), BX
MOVQ a+24(FP), CX
MOVQ $128, BP
MOVQ c+24(FP), CX
MOVQ $128, DI

loop:
MOVOU 0(AX), X0
Expand All @@ -239,6 +238,6 @@ loop:
ADDQ $16, BX
ADDQ $16, CX
ADDQ $16, DX
SUBQ $2, BP
SUBQ $2, DI
JA loop
RET
1 change: 0 additions & 1 deletion argon2/blamka_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !amd64 || purego || !gc
// +build !amd64 purego !gc

package argon2

Expand Down
3 changes: 1 addition & 2 deletions blake2b/blake2bAVX2_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.7 && amd64 && gc && !purego
// +build go1.7,amd64,gc,!purego
//go:build amd64 && gc && !purego

package blake2b

Expand Down
3 changes: 1 addition & 2 deletions blake2b/blake2bAVX2_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.7 && amd64 && gc && !purego
// +build go1.7,amd64,gc,!purego
//go:build amd64 && gc && !purego

#include "textflag.h"

Expand Down
25 changes: 0 additions & 25 deletions blake2b/blake2b_amd64.go

This file was deleted.

1 change: 0 additions & 1 deletion blake2b/blake2b_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build amd64 && gc && !purego
// +build amd64,gc,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion blake2b/blake2b_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !amd64 || purego || !gc
// +build !amd64 purego !gc

package blake2b

Expand Down
3 changes: 0 additions & 3 deletions blake2b/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.9
// +build go1.9

package blake2b

import (
Expand Down
1 change: 0 additions & 1 deletion blake2s/blake2s_386.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build 386 && gc && !purego
// +build 386,gc,!purego

package blake2s

Expand Down
1 change: 0 additions & 1 deletion blake2s/blake2s_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build 386 && gc && !purego
// +build 386,gc,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion blake2s/blake2s_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build amd64 && gc && !purego
// +build amd64,gc,!purego

package blake2s

Expand Down
1 change: 0 additions & 1 deletion blake2s/blake2s_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build amd64 && gc && !purego
// +build amd64,gc,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion blake2s/blake2s_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build (!amd64 && !386) || !gc || purego
// +build !amd64,!386 !gc purego

package blake2s

Expand Down
1 change: 0 additions & 1 deletion blake2s/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build go1.9
// +build go1.9

package blake2s

Expand Down
3 changes: 1 addition & 2 deletions chacha20/chacha_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.11 && gc && !purego
// +build go1.11,gc,!purego
//go:build gc && !purego

package chacha20

Expand Down
3 changes: 1 addition & 2 deletions chacha20/chacha_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.11 && gc && !purego
// +build go1.11,gc,!purego
//go:build gc && !purego

#include "textflag.h"

Expand Down
3 changes: 1 addition & 2 deletions chacha20/chacha_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build (!arm64 && !s390x && !ppc64le) || (arm64 && !go1.11) || !gc || purego
// +build !arm64,!s390x,!ppc64le arm64,!go1.11 !gc purego
//go:build (!arm64 && !s390x && !ppc64le) || !gc || purego

package chacha20

Expand Down
1 change: 0 additions & 1 deletion chacha20/chacha_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build gc && !purego
// +build gc,!purego

package chacha20

Expand Down
1 change: 0 additions & 1 deletion chacha20/chacha_ppc64le.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// due to the calling conventions and initialization of constants.

//go:build gc && !purego
// +build gc,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion chacha20/chacha_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build gc && !purego
// +build gc,!purego

package chacha20

Expand Down
1 change: 0 additions & 1 deletion chacha20/chacha_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build gc && !purego
// +build gc,!purego

#include "go_asm.h"
#include "textflag.h"
Expand Down
1 change: 0 additions & 1 deletion chacha20poly1305/chacha20poly1305_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build gc && !purego
// +build gc,!purego

package chacha20poly1305

Expand Down
25 changes: 22 additions & 3 deletions chacha20poly1305/chacha20poly1305_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// This file was originally from https://golang.org/cl/24717 by Vlad Krasnov of CloudFlare.

//go:build gc && !purego
// +build gc,!purego

#include "textflag.h"
// General register allocation
Expand Down Expand Up @@ -184,11 +183,31 @@ GLOBL ·andMask<>(SB), (NOPTR+RODATA), $240
#define shiftD1Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xd2; BYTE $0x04 // PALIGNR $4, X10, X10
#define shiftD2Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xdb; BYTE $0x04 // PALIGNR $4, X11, X11
#define shiftD3Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xff; BYTE $0x04 // PALIGNR $4, X15, X15

// Some macros

// ROL rotates the uint32s in register R left by N bits, using temporary T.
#define ROL(N, R, T) \
MOVO R, T; PSLLL $(N), T; PSRLL $(32-(N)), R; PXOR T, R

// ROL16 rotates the uint32s in register R left by 16, using temporary T if needed.
#ifdef GOAMD64_v2
#define ROL16(R, T) PSHUFB ·rol16<>(SB), R
#else
#define ROL16(R, T) ROL(16, R, T)
#endif

// ROL8 rotates the uint32s in register R left by 8, using temporary T if needed.
#ifdef GOAMD64_v2
#define ROL8(R, T) PSHUFB ·rol8<>(SB), R
#else
#define ROL8(R, T) ROL(8, R, T)
#endif

#define chachaQR(A, B, C, D, T) \
PADDD B, A; PXOR A, D; PSHUFB ·rol16<>(SB), D \
PADDD B, A; PXOR A, D; ROL16(D, T) \
PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $12, T; PSRLL $20, B; PXOR T, B \
PADDD B, A; PXOR A, D; PSHUFB ·rol8<>(SB), D \
PADDD B, A; PXOR A, D; ROL8(D, T) \
PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $7, T; PSRLL $25, B; PXOR T, B

#define chachaQR_AVX2(A, B, C, D, T) \
Expand Down
1 change: 0 additions & 1 deletion chacha20poly1305/chacha20poly1305_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !amd64 || !gc || purego
// +build !amd64 !gc purego

package chacha20poly1305

Expand Down
13 changes: 7 additions & 6 deletions cryptobyte/asn1.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,14 @@ func (s *String) ReadOptionalASN1OctetString(out *[]byte, outPresent *bool, tag
return true
}

// ReadOptionalASN1Boolean sets *out to the value of the next ASN.1 BOOLEAN or,
// if the next bytes are not an ASN.1 BOOLEAN, to the value of defaultValue.
// It reports whether the operation was successful.
func (s *String) ReadOptionalASN1Boolean(out *bool, defaultValue bool) bool {
// ReadOptionalASN1Boolean attempts to read an optional ASN.1 BOOLEAN
// explicitly tagged with tag into out and advances. If no element with a
// matching tag is present, it sets "out" to defaultValue instead. It reports
// whether the read was successful.
func (s *String) ReadOptionalASN1Boolean(out *bool, tag asn1.Tag, defaultValue bool) bool {
var present bool
var child String
if !s.ReadOptionalASN1(&child, &present, asn1.BOOLEAN) {
if !s.ReadOptionalASN1(&child, &present, tag) {
return false
}

Expand All @@ -748,7 +749,7 @@ func (s *String) ReadOptionalASN1Boolean(out *bool, defaultValue bool) bool {
return true
}

return s.ReadASN1Boolean(out)
return child.ReadASN1Boolean(out)
}

func (s *String) readASN1(out *String, outTag *asn1.Tag, skipHeader bool) bool {
Expand Down
22 changes: 22 additions & 0 deletions cryptobyte/asn1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ func TestReadASN1OptionalInteger(t *testing.T) {
}
}

const defaultBool = false

var optionalBoolTestData = []readASN1Test{
{"empty", []byte{}, 0xa0, true, false},
{"invalid", []byte{0xa1, 0x3, 0x1, 0x2, 0x7f}, 0xa1, false, defaultBool},
{"missing", []byte{0xa1, 0x3, 0x1, 0x1, 0x7f}, 0xa0, true, defaultBool},
{"present", []byte{0xa1, 0x3, 0x1, 0x1, 0xff}, 0xa1, true, true},
}

func TestReadASN1OptionalBoolean(t *testing.T) {
for _, test := range optionalBoolTestData {
t.Run(test.name, func(t *testing.T) {
in := String(test.in)
var out bool
ok := in.ReadOptionalASN1Boolean(&out, test.tag, defaultBool)
if ok != test.ok || ok && out != test.out.(bool) {
t.Errorf("in.ReadOptionalASN1Boolean() = %v, want %v; out = %v, want %v", ok, test.ok, out, test.out)
}
})
}
}

func TestReadASN1IntegerSigned(t *testing.T) {
testData64 := []struct {
in []byte
Expand Down
5 changes: 5 additions & 0 deletions cryptobyte/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (b *Builder) AddUint32(v uint32) {
b.add(byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
}

// AddUint48 appends a big-endian, 48-bit value to the byte string.
func (b *Builder) AddUint48(v uint64) {
b.add(byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
}

// AddUint64 appends a big-endian, 64-bit value to the byte string.
func (b *Builder) AddUint64(v uint64) {
b.add(byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
Expand Down
Loading