Daniel Mangum
e90f1e17ee
cryptobyte: add uint48 methods
...
Adds uint48 methods for cryptobyte.Builder and cryptobyte.String.
Supporting 48-bit unsigned integers is useful for working with protocols
that use them for sequence numbers, such as DTLS.
Fixes golang/go#61275
Change-Id: Ibe49422d37644b9212b28b123dc5e01850f7b05b
GitHub-Last-Rev: 11b388c240109c8f4ac23880645c901ce6d2f093
GitHub-Pull-Request: golang/crypto#265
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/508675
Reviewed-by: Roland Shoemaker <roland@golang.org >
Reviewed-by: Cherry Mui <cherryyz@google.com >
Reviewed-by: qiulaidongfeng <2645477756@qq.com >
Run-TryBot: Roland Shoemaker <roland@golang.org >
Auto-Submit: Roland Shoemaker <roland@golang.org >
TryBot-Result: Gopher Robot <gobot@golang.org >
2023-09-07 16:27:37 +00:00
Mateusz Poliwczak
1faeef9713
cryptobyte: reject Object Identifiers with leading 0x80
...
Change-Id: Ie3a1b53e801077cd86963799e644b9783943933c
GitHub-Last-Rev: 6629bd74f1874eb9fde8e72bfb444ebf9073a1ab
GitHub-Pull-Request: golang/crypto#255
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/483955
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com >
TryBot-Result: Gopher Robot <gobot@golang.org >
Reviewed-by: Ian Lance Taylor <iant@google.com >
Auto-Submit: Ian Lance Taylor <iant@google.com >
Reviewed-by: Roland Shoemaker <roland@golang.org >
Run-TryBot: Ian Lance Taylor <iant@google.com >
2023-04-12 18:30:42 +00:00
Alexander Yastrebov
310bfa40f1
cryptobyte: reject negative Unwrite argument
...
Fixes golang/go#57112
Change-Id: I7a533046a6451d7ae3704eb81e6ddeec8442cf06
GitHub-Last-Rev: 3b088d95a2feca197cc4ebd1d9d34cb28008349f
GitHub-Pull-Request: golang/crypto#249
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/464338
TryBot-Result: Gopher Robot <gobot@golang.org >
Auto-Submit: Roland Shoemaker <roland@golang.org >
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com >
Reviewed-by: Roland Shoemaker <roland@golang.org >
Run-TryBot: Roland Shoemaker <roland@golang.org >
Reviewed-by: Bryan Mills <bcmills@google.com >
2023-02-03 19:59:27 +00:00
cui fliter
59ff47295c
all: fix some comments
...
Change-Id: I11030ee466c8cac6855ce4fe2cf72e0b8d7029f8
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/463796
Auto-Submit: Ian Lance Taylor <iant@google.com >
Reviewed-by: Michael Knyszek <mknyszek@google.com >
Run-TryBot: Ian Lance Taylor <iant@google.com >
TryBot-Result: Gopher Robot <gobot@golang.org >
Reviewed-by: Ian Lance Taylor <iant@google.com >
2023-01-30 18:50:24 +00:00
Filippo Valsorda
2c476679df
cryptobyte: add support for ReadASN1Integer into []byte
...
This lets us extract large integers without involving math/big.
While at it, drop some use of reflect where a type switch will do.
Change-Id: Iebe2fb2267610bf95cf9747ba1d49b5ac9e62cda
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/451515
Run-TryBot: Filippo Valsorda <filippo@golang.org >
Reviewed-by: Damien Neil <dneil@google.com >
Reviewed-by: Bryan Mills <bcmills@google.com >
Reviewed-by: Roland Shoemaker <roland@golang.org >
TryBot-Result: Gopher Robot <gobot@golang.org >
Auto-Submit: Filippo Valsorda <filippo@golang.org >
2022-11-17 19:18:49 +00:00
cui fliter
21d60a1521
all: remove redundant type conversion
...
Change-Id: Ic6b210c1e5b99eef5c6e38d96feaf40e7e6033bb
GitHub-Last-Rev: b8ecf761efe6a2eec78a805a99d778bdcdb938f9
GitHub-Pull-Request: golang/crypto#229
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/429016
Run-TryBot: Ian Lance Taylor <iant@google.com >
Reviewed-by: Ian Lance Taylor <iant@google.com >
TryBot-Result: Gopher Robot <gobot@golang.org >
Reviewed-by: Michael Knyszek <mknyszek@google.com >
2022-11-09 16:50:04 +00:00
hopehook
5757bc0c55
cryptobyte: add ReadUint64 and AddUint64
...
Fixes golang/go#53481 .
Change-Id: Ic00eef498d1d3b5b0ca5c9c526fac7c26de30cf2
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/421014
TryBot-Result: Gopher Robot <gobot@golang.org >
Auto-Submit: Filippo Valsorda <filippo@golang.org >
Run-TryBot: hopehook <hopehook@qq.com >
Reviewed-by: Damien Neil <dneil@google.com >
Reviewed-by: Roland Shoemaker <roland@golang.org >
2022-08-24 17:17:10 +00:00
Russ Cox
7b82a4e95d
all: gofmt
...
Gofmt to update doc comments to the new formatting.
For golang/go#51082 .
Change-Id: I076031b6613691eefbb0f21739366e3fd2011ec9
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/399356
Run-TryBot: Russ Cox <rsc@golang.org >
TryBot-Result: Gopher Robot <gobot@golang.org >
Auto-Submit: Russ Cox <rsc@golang.org >
Reviewed-by: Ian Lance Taylor <iant@google.com >
2022-04-11 22:02:26 +00:00
umlublin
e495a2d5b3
cryptobyte: fix parsing of large ASN.1 OIDs
...
Fixes golang/go#49678
Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674
Reviewed-by: Filippo Valsorda <filippo@golang.org >
Run-TryBot: Filippo Valsorda <filippo@golang.org >
Trust: Alex Rakoczy <alex@golang.org >
Trust: Bryan Mills <bcmills@google.com >
TryBot-Result: Gopher Robot <gobot@golang.org >
2021-12-15 15:39:01 +00:00
Roland Shoemaker
4f45737414
cryptobyte: add support for UTCTime
...
Mostly cribbed from encoding/asn1.parseUTCTime.
Fixes golang/go#45411
Change-Id: I6c6ab2a2ad7c05a7f8bd81ecce4fcbb4e608e8db
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/273286
Trust: Roland Shoemaker <roland@golang.org >
Trust: Katie Hockman <katie@golang.org >
Run-TryBot: Roland Shoemaker <roland@golang.org >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Katie Hockman <katie@golang.org >
2021-04-15 15:40:28 +00:00
Pasi Tähkäpää
06a226fb4e
Use boolean tag (0x01) for boolean type.
...
Fix for problem with ReadASN1Boolean, which uses invalid tag (Integer / 0x02) when trying to read boolean value. This is a fix for the one case mentioned in "x/crypto/cryptobyte: cannot read boolean values #26565 "
This is specified in ITU-T X.690, section 8.2, with DER additions specified in 11.1.
Change-Id: I3c9406bd6febb6112f380224fec1d42a6cd64ed4
GitHub-Last-Rev: fd7d01c897d8aa32d92115be9017f84d75fc4467
GitHub-Pull-Request: golang/crypto#137
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/233161
Reviewed-by: Adam Langley <agl@golang.org >
Run-TryBot: Adam Langley <agl@golang.org >
TryBot-Result: Gobot Gobot <gobot@golang.org >
2020-05-10 22:35:06 +00:00
Katie Hockman
18b771bd64
cryptobyte: handle AddASN1BigInt with -1
...
Fixes golang/go#38510
Change-Id: Ie52db22bf85a5f79046fad95e5bbe2788c3bec92
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/229457
Reviewed-by: Filippo Valsorda <filippo@golang.org >
2020-04-23 19:51:18 +00:00
Filippo Valsorda
69ecbb4d6d
cryptobyte: fix panic due to malformed ASN.1 inputs on 32-bit archs
...
When int is 32 bits wide (on 32-bit architectures like 386 and arm), an
overflow could occur, causing a panic, due to malformed ASN.1 being
passed to any of the ASN1 methods of String.
Tested on linux/386 and darwin/amd64.
This fixes CVE-2020-7919 and was found thanks to the Project Wycheproof
test vectors.
Change-Id: I8c9696a8bfad1b40ec877cd740dba3467d66ab54
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/645211
Reviewed-by: Katie Hockman <katiehockman@google.com >
Reviewed-by: Adam Langley <agl@google.com >
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/216677
Run-TryBot: Katie Hockman <katie@golang.org >
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org >
Reviewed-by: Filippo Valsorda <filippo@golang.org >
TryBot-Result: Gobot Gobot <gobot@golang.org >
2020-01-28 17:40:31 +00:00
Philipp
c05539cddb
cryptobyte: fix typo in test
...
Change-Id: I03178eca962c29ad03fd9b2fb57ad35c53c99860
GitHub-Last-Rev: 21a7a751920a5d3e650d1f91d17177f33e477ff1
GitHub-Pull-Request: golang/crypto#66
Reviewed-on: https://go-review.googlesource.com/c/151277
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
2018-11-26 14:41:56 +00:00
Filippo Valsorda
3d3f9f4138
cryptobyte: don't ignore bytes added to BuilderContinuations of fixed-size Builders
...
Builders created with NewFixedBuilder were broken when used with
BuilderContinuations. The length of the bytes written to the
continuation would get added correctly to the parent, but the actual
content would be discarded.
For example, the BytesOrPanic() in TestFixedBuilderLengthPrefixed would
return [00 08] instead of [00 08 ff ff ff ff ff ff ff ff].
Change-Id: I80837a9bf3562751addcb827274649d9f52fc79a
Reviewed-on: https://go-review.googlesource.com/c/148882
Run-TryBot: Filippo Valsorda <filippo@golang.org >
TryBot-Result: Gobot Gobot <gobot@golang.org >
Reviewed-by: Adam Langley <agl@golang.org >
2018-11-12 20:29:54 +00:00
Filippo Valsorda
b078efbc80
cryptobyte: add (*Builder).Unwrite and (*Builder).SetError
...
Unwrite allows programs to rollback builders more reliably and
efficiently than by copying a Builder (which might waste an allocation
and depends on internal behavior). This is useful for example to remove
a length-prefixed field if it ends up being empty.
SetError allows simple Builder extensions to set errors without making
MarshalingValue wrappers.
Based on the experience of CL 144115.
Change-Id: I9a785b81b51b15af49418b5bdb71c4ef222ccc46
Reviewed-on: https://go-review.googlesource.com/c/145317
Reviewed-by: Adam Langley <agl@golang.org >
2018-10-29 21:22:43 +00:00
Igor Zhilianin
45a5f77698
all: fix typos
...
Change-Id: I62cbcfcd0be5f6a74d93b85b24ff7607533bb239
GitHub-Last-Rev: 9967869e706e9fe7d13964bb32b30a44ba640869
GitHub-Pull-Request: golang/crypto#64
Reviewed-on: https://go-review.googlesource.com/c/145240
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
2018-10-29 02:12:03 +00:00
Andrey Mirtchovski
e73bf333ef
x/crypto: cryptobyte: manage integers with implicit tags
...
This change adds two functions to cryptobyte to encode and decode
int64 with tags supplied by the user.
This change also modifies a documentation comment which was outdated.
Fixes golang/go#24973
Change-Id: I2e3ca475891ba62df902f33085719f94e87a27cc
GitHub-Last-Rev: cd0300d9bfbd4e38f22503a046ea18f9ddd37676
GitHub-Pull-Request: golang/crypto#42
Reviewed-on: https://go-review.googlesource.com/108456
Reviewed-by: Adam Langley <agl@golang.org >
2018-04-20 17:11:55 +00:00
Andrey Mirtchovski
f70185d77e
cryptobyte: minor documentation fix
...
This change fixes a minor misspelling in the documentation for ReadBytes.
Change-Id: Ia1cfedfce11844c4d901b9aeed52065f3749dfa2
GitHub-Last-Rev: d1560b97807871c356d1b704d4879b1cf94a3fd8
GitHub-Pull-Request: golang/crypto#40
Reviewed-on: https://go-review.googlesource.com/106116
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
2018-04-10 18:26:41 +00:00
Adam Langley
faadfbdc03
cryptobyte: include changes from review of 57810
...
I forgot to upload the final set of changes before submitting.
Change-Id: I3e60c6e2aad25af7f5007fc5ffbf8a1a1e1a91f3
Reviewed-on: https://go-review.googlesource.com/63331
Reviewed-by: Adam Langley <agl@golang.org >
2017-09-12 19:18:25 +00:00
Adam Langley
2bcb7b5baf
cryptobyte: various API and documentation updates.
...
Change-Id: I83236ecea0774d4ec49e978a391eb3ff5dabdeb6
Reviewed-on: https://go-review.googlesource.com/57810
Reviewed-by: Martin Kreichgauer <martinkr@google.com >
Reviewed-by: Adam Langley <agl@golang.org >
2017-09-12 17:47:39 +00:00
Andreas Auernhammer
55a552f082
x/crypto/*: add import comment
...
Add import comment for blake2b, blake2s, chacha20poly1305 and cryptobyte.
Change-Id: I4703b5cd669e43a5d81422b2ded8b8f54eee5f9b
Reviewed-on: https://go-review.googlesource.com/39952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org >
2017-04-07 17:36:45 +00:00
Martin Kreichgauer
728b753d01
cryptobyte: new package.
...
cryptobyte is a helper library for building and parsing byte strings,
specifically for TLS and ASN.1.
Change-Id: I046b94773f6781153784c79f3d81e6d464eaebe0
Reviewed-on: https://go-review.googlesource.com/36123
Reviewed-by: Adam Langley <agl@golang.org >
Run-TryBot: Adam Langley <agl@golang.org >
TryBot-Result: Gobot Gobot <gobot@golang.org >
2017-03-07 00:40:51 +00:00