commit_hash
stringlengths
40
40
author
stringlengths
1
57
date
timestamp[s]date
2010-07-26 04:45:09
2026-04-14 18:21:10
message
stringlengths
8
1.39M
diff
stringlengths
68
51.2k
files_changed
int64
1
136
insertions
int64
0
2.35k
deletions
int64
0
1.9k
cd0d57475708930fab79f137a4faaa4338a35ebe
Tony Arcieri
2021-02-22T19:53:09
der_derive: custom derive support for `Choice` (#296) Adds support for deriving the `Choice` macro for enums
diff --git a/der/derive/src/choice.rs b/der/derive/src/choice.rs index 8a3afe2..d0fde0a 100644 --- a/der/derive/src/choice.rs +++ b/der/derive/src/choice.rs @@ -8,13 +8,22 @@ use quote::{quote, ToTokens}; use syn::{DataEnum, Lifetime}; use synstructure::{Structure, VariantInfo}; -/// Derive `Decodable` for an enum....
5
143
160
22ec3c994eb066c75bf844b06ad94eccce933a29
Tony Arcieri
2021-02-22T18:46:57
der: add `Choice` trait (#295) Closes #271 The `Choice` trait represents an ASN.1 `CHOICE` and allows types to specify which ASN.1 tags they support. This is implemented in terms of a static `can_decode` method. Using a method for this means it's possible to impl `Choice` for `Any` (or e.g. enums that contain...
diff --git a/der/src/asn1.rs b/der/src/asn1.rs index 7a635c4..f7fb0a1 100644 --- a/der/src/asn1.rs +++ b/der/src/asn1.rs @@ -7,6 +7,7 @@ pub(crate) mod any; pub(crate) mod big_uint; pub(crate) mod bit_string; pub(crate) mod boolean; +pub(crate) mod choice; pub(crate) mod generalized_time; pub(crate) mod integer; ...
7
60
10
34178cce45cc1486243d3cc8f29c319515533ecb
Tony Arcieri
2021-02-22T17:56:47
der: refactor traits into their own modules (#294) This makes them easier to find, and also the monolithic `traits` module was getting unwieldy and we're about ready to add some more.
diff --git a/der/src/asn1/big_uint.rs b/der/src/asn1/big_uint.rs index 29e657f..c8a15d6 100644 --- a/der/src/asn1/big_uint.rs +++ b/der/src/asn1/big_uint.rs @@ -197,7 +197,7 @@ impl_size!( #[cfg(test)] mod tests { use super::BigUInt; - use crate::{asn1::integer::tests::*, traits::Decodable, Any, ErrorKind, Re...
9
160
135
e976575716f69b563a84adf4e88815f5f90ae17f
Tony Arcieri
2021-02-20T16:14:38
pkcs8: use `pkcs5` crate (#290) Adds the `pkcs5` crate as an optional dependency (replacing the previous `pkcs5` feature with an optional crate). Uses the `pkcs5` crate for parsing the `AlgorithmIdentifier` of `EncryptedPrivateKeyInfo`.
diff --git a/Cargo.lock b/Cargo.lock index 402e0f3..b257e2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,6 +114,7 @@ dependencies = [ "base64ct", "der", "hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pkcs5", "spki", "zeroize", ] diff --git a/pkcs5/src/lib.rs b/pkcs5/src/l...
7
68
43
55a415731fbf5db3eb8bcb40f09d1a8bdddad0fb
Tony Arcieri
2021-02-19T19:51:54
pkcs5: add encoding support (#285) Adds support for re-encoding the parsed `Scheme` as ASN.1 DER
diff --git a/der/src/encoder.rs b/der/src/encoder.rs index c5a3584..9092da1 100644 --- a/der/src/encoder.rs +++ b/der/src/encoder.rs @@ -162,6 +162,7 @@ impl<'a> Encoder<'a> { } /// Encode a sequence of values which impl the [`Encodable`] trait. + // TODO(tarcieri): rename this to `message`, add `sequenc...
5
293
53
2ea5e20bea56eedd43414232bffda69eda28e2ca
Tony Arcieri
2021-02-19T19:26:54
const-oid: fix root arc calculation (#284) It was using bitwise OR instead of addition. This commit also significantly expands the tests, including adding test cases for a root arc of 2, assertions for the root arcs everywhere (as they are represented differently internally), and additionally moves tests into th...
diff --git a/Cargo.lock b/Cargo.lock index 21dab65..9345305 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,9 @@ version = "0.0.2" [[package]] name = "const-oid" version = "0.4.1" +dependencies = [ + "hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cpuid-b...
5
145
103
e240036c80225acba7d90aec0bbfb33912fbde87
Tony Arcieri
2021-02-19T16:31:07
der: export `Header` publically (#283) Advanced usages of the crate (which try to map DER-encoded data in a way that isn't 100% isomorphic to Rust struct/enum combinations) can benefit from having this available in the public interface.
diff --git a/der/src/header.rs b/der/src/header.rs index 83b2761..c08f799 100644 --- a/der/src/header.rs +++ b/der/src/header.rs @@ -5,7 +5,7 @@ use core::convert::TryInto; /// ASN.1 DER headers: tag + length component of TLV-encoded values #[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub(crate) struct Header { +p...
2
4
3
638e2b4b76c3d61d90a0023151e856dffda664e3
Tony Arcieri
2021-02-19T16:02:42
der: make the unit type an encoding of `NULL` (#281)
diff --git a/der/src/asn1/null.rs b/der/src/asn1/null.rs index 0f20331..b3c56a8 100644 --- a/der/src/asn1/null.rs +++ b/der/src/asn1/null.rs @@ -41,6 +41,40 @@ impl Tagged for Null { const TAG: Tag = Tag::Integer; } +impl TryFrom<Any<'_>> for () { + type Error = Error; + + fn try_from(any: Any<'_>) -> Res...
2
66
26
b8faca5f569a5efb14bd71342918dd72994c5eb9
Tony Arcieri
2021-02-19T02:43:02
der: rename OidInvalid => UnknownOid (#275) This name does a much better job of capturing what it is attempting to report to the caller, and also nicely pairs with `UnknownTag`.
diff --git a/der/src/error.rs b/der/src/error.rs index d0b44d1..2581177 100644 --- a/der/src/error.rs +++ b/der/src/error.rs @@ -103,7 +103,11 @@ impl std::error::Error for ErrorKind {} #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum ErrorKind { - /// Operation failed due to previous error...
3
29
16
9680af5041c8402eae4cfc01a2e39e505db01151
Tony Arcieri
2021-02-18T17:20:06
spki: return `Result` from `AlgorithmIdentifier::params_*` (#274) Returning a result makes for simpler error handling with `?` in functions which also return a `Result`, and also makes it possible to propagate incompatible DER tags encountered when using these methods.
diff --git a/spki/src/algorithm.rs b/spki/src/algorithm.rs index 924440a..876e0a3 100644 --- a/spki/src/algorithm.rs +++ b/spki/src/algorithm.rs @@ -27,18 +27,34 @@ pub struct AlgorithmIdentifier<'a> { impl<'a> AlgorithmIdentifier<'a> { /// Get the `parameters` field as an [`Any`]. /// - /// This will be ...
1
33
8
6aa105866cadc287c82386e9d1990d3e22c11ee1
Tony Arcieri
2021-02-18T17:03:14
der: add ErrorKind::OidInvalid (#273) Adds an error variant for propagating OIDs as discussed in #272. It's a little awkward for a few reasons: - There's already a unit `ErrorKind::Oid` variant. Since that's a little ambiguous, there's also a TODO to rename that variant to the more specific `ErrorKind::Oid...
diff --git a/der/src/error.rs b/der/src/error.rs index 5516f7e..d0b44d1 100644 --- a/der/src/error.rs +++ b/der/src/error.rs @@ -5,21 +5,24 @@ pub use core::str::Utf8Error; use crate::{Length, Tag}; use core::{convert::Infallible, fmt}; +#[cfg(feature = "oid")] +use crate::ObjectIdentifier; + /// Result type. pub...
1
37
22
3c0d7ca29c7a2452ec56cb93ee15f193c6eca991
Tony Arcieri
2021-02-17T03:05:14
spki: add (back) an `AlgorithmParameters` type (#267) Adds an enum representing `ANY`, `NULL`, and `Objectidentifier` cases for the `parameters` field of `AlgorithmIdentifier`. Ideally this enum would be unnecessary and we could just use the `der::Any` type for this field, however to make that possible in all re...
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index d9814f1..488c2b7 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -103,15 +103,18 @@ impl std::error::Error for Error {} /// Result type pub type Result<T> = core::result::Result<T, Error>; -/// Object identifier (OID) +/// Object identif...
4
127
12
f1a555dfdfa8c4813f8326e0f2030d836693718c
Tony Arcieri
2021-02-17T00:50:58
pkcs8: add tracking issues for PKCS#8 encryption support (#264) Updates the rustdoc with links to #263
diff --git a/pkcs8/src/lib.rs b/pkcs8/src/lib.rs index 510e004..4d3fe7c 100644 --- a/pkcs8/src/lib.rs +++ b/pkcs8/src/lib.rs @@ -35,6 +35,9 @@ //! private keys. //! //! However, support for actually decrypting/encrypting them remains TBD. +//! Please see the following GitHub issue for more information: +//! +//! <ht...
2
10
5
7b38a1776f0a41c83e48558962fb56a0381af314
Tony Arcieri
2021-02-15T18:32:58
der_derive: fix typo in rustdoc (#260)
diff --git a/der/derive/src/lib.rs b/der/derive/src/lib.rs index 4207764..39b132a 100644 --- a/der/derive/src/lib.rs +++ b/der/derive/src/lib.rs @@ -15,7 +15,7 @@ //! This attribute can be used to specify the ASN.1 type for a particular //! enum variant or struct field. //! -//! It's presently mandatory for all stru...
1
1
1
4f9875413742fc76712e6df915bb7ab295ffb5ca
Tony Arcieri
2021-02-15T17:41:48
der_derive: fix typo (#259)
diff --git a/der/derive/src/lib.rs b/der/derive/src/lib.rs index 0ba417d..4207764 100644 --- a/der/derive/src/lib.rs +++ b/der/derive/src/lib.rs @@ -99,7 +99,7 @@ decl_derive!( /// Derive the [`Encodable`][1] trait on an enum. /// /// This custom derive macro can be used to automatically impl the - //...
1
1
1
eb1285a249b09cf78c22f383704ec86412666599
Tony Arcieri
2021-02-15T15:38:33
der_derive: improve rustdoc documentation (#256)
diff --git a/der/derive/src/lib.rs b/der/derive/src/lib.rs index d334608..0ba417d 100644 --- a/der/derive/src/lib.rs +++ b/der/derive/src/lib.rs @@ -1,4 +1,62 @@ -//! Custom derive support for the `der` crate +//! Custom derive support for the [`der`] crate. +//! +//! This crate contains custom derive macros intended t...
1
86
17
0b322580a60dca60f7f89abf74afc914438c7d1e
Tony Arcieri
2021-02-15T02:11:40
der_derive: custom derive support for enums (#254) Adds custom derive support for mapping ASN.1 `CHOICE` to Rust enums.
diff --git a/der/derive/src/attributes.rs b/der/derive/src/attributes.rs new file mode 100644 index 0000000..bf22bad --- /dev/null +++ b/der/derive/src/attributes.rs @@ -0,0 +1,50 @@ +//! Attribute-related types used by the proc macro + +use crate::Asn1Type; +use syn::{Attribute, Lit, Meta, MetaList, MetaNameValue, Nes...
10
651
228
75bf0026f2de5debb4d9898766748ee699822ee3
Tony Arcieri
2021-02-14T23:52:11
der: add notes about ASN.1 ANY type (#252)
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index 5580d13..abe7059 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -9,7 +9,15 @@ use core::convert::{TryFrom, TryInto}; #[cfg(feature = "oid")] use crate::ObjectIdentifier; -/// ASN.1 `ANY` type: represents any explicitly tagged ASN.1 value. +...
1
9
1
6fc45c92c806641bb507ae4082031c5d0a858cce
Tony Arcieri
2021-02-12T21:04:21
der: UTCTime and GeneralizedTime support (#250) Adds support for two ASN.1 datetime types: - `UTCTime` (as a `UtcTime` struct) - `GeneralizedTime` Both types are implemented as newtypes around a `Duration` representing the amount of time since `UNIX_EPOCH` so as to support `no_std` targets that do not have `S...
diff --git a/Cargo.lock b/Cargo.lock index 97fe877..30798c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,7 @@ version = "0.2.1" dependencies = [ "const-oid", "der_derive", + "hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "typenum", ] diff --git a/der/Cargo.toml b/der/Car...
8
690
0
0eb16d3e72732f8482bc7863d63e5fbc1c5578d9
Artyom Pavlov
2021-02-11T01:40:00
block-buffer: add delimiter argument to digest_pad (#248)
diff --git a/Cargo.lock b/Cargo.lock index 991a70d..97fe877 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,7 +13,7 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.0-pre.1" +version = "0.10.0-pre.2" dependencies = [ "block-padding", "generic-array", diff --git a/block-buffer/Cargo.toml b...
3
13
8
2788df5f564b5c6044b6689a60c1b1449ddd9559
Tony Arcieri
2021-02-02T22:31:30
der: better PrintableString docs (#247)
diff --git a/der/src/asn1/printable_string.rs b/der/src/asn1/printable_string.rs index 444fd07..3e9ead4 100644 --- a/der/src/asn1/printable_string.rs +++ b/der/src/asn1/printable_string.rs @@ -8,8 +8,28 @@ use core::{convert::TryFrom, fmt, str}; /// ASN.1 `PrintableString` type. /// -/// Supports only the ASCII cha...
1
21
1
3316b1988160cd6f630ec89da6eba9db7c47e48b
Tony Arcieri
2021-02-02T21:23:51
der: add support for PrintableString and Utf8String (#245) Also impls `Decodable`/`Encodable` traits for `str`
diff --git a/der/derive/src/lib.rs b/der/derive/src/lib.rs index 21c4be7..97b7edf 100644 --- a/der/derive/src/lib.rs +++ b/der/derive/src/lib.rs @@ -28,6 +28,8 @@ decl_derive!( /// /// - `bit-string`: performs an intermediate conversion to `der::BitString` /// - `octet-string`: performs an intermediate c...
10
484
3
5f202c8a535b7f41c8d12f3c7a7e2d45c2f20a7a
Tony Arcieri
2021-02-01T15:21:36
base64ct: move variant impls under the `variant` module (#242)
diff --git a/base64ct/src/encoding.rs b/base64ct/src/encoding.rs index a87f23b..7b3d24c 100644 --- a/base64ct/src/encoding.rs +++ b/base64ct/src/encoding.rs @@ -12,7 +12,10 @@ use alloc::{string::String, vec::Vec}; /// Padding character const PAD: u8 = b'='; -/// Base64 encoding +/// Base64 encoding trait. +/// +//...
7
19
13
59e27136c5b25848488344a174f2f2ec9aa08461
Tony Arcieri
2021-02-01T15:15:11
base64ct: declarative decoding/encoding (#241) Replaces imperative decode_6bits/encode_6bits method with declarative associated constants describing the encoding. This method still avoids the use of lookup tables and all inputs are still processed identically without any branching.
diff --git a/base64ct/src/bcrypt.rs b/base64ct/src/bcrypt.rs index e0d662a..7819b52 100644 --- a/base64ct/src/bcrypt.rs +++ b/base64ct/src/bcrypt.rs @@ -1,9 +1,6 @@ //! bcrypt Base64 encoding. -use crate::{ - encoding::{match_gt_ct, match_range_ct}, - variant::Variant, -}; +use crate::variant::{Decode, Encode,...
6
180
195
ca602ad5e278b6c3bd6e1b2becd7ef1f9c8e59df
Tony Arcieri
2021-02-01T00:19:23
base64ct: crypt(3) encoding (#239) Used by SHA-crypt
diff --git a/base64ct/src/encoding.rs b/base64ct/src/encoding.rs index 97d8e65..3d3a9a3 100644 --- a/base64ct/src/encoding.rs +++ b/base64ct/src/encoding.rs @@ -1,5 +1,6 @@ //! Base64 encodings pub mod bcrypt; +pub mod crypt; pub(crate) mod standard; pub mod url; diff --git a/base64ct/src/encoding/bcrypt.rs b/bas...
7
150
5
094bfc67aad956d8028eb564b9602e43b12725a2
Tony Arcieri
2021-01-31T21:52:25
base64ct: bcrypt encoding (#237) Adds the Base64 variant used by bcrypt
diff --git a/base64ct/src/decoder.rs b/base64ct/src/decoder.rs index 42220c2..c13be36 100644 --- a/base64ct/src/decoder.rs +++ b/base64ct/src/decoder.rs @@ -8,12 +8,15 @@ use alloc::vec::Vec; /// Decode the provided Base64 string into the provided destination buffer. #[inline(always)] -pub(crate) fn decode( +pub(cr...
12
589
390
ff20f14e659a514e9344e8648b8736ab343593fe
Tony Arcieri
2021-01-31T18:42:39
base64ct: refactor encoder functions (#236) To make it easier to support the "crypt" encoding (which is slightly different from the others as the alphabet is shifted), this change refactors encoders to support an arbitrary `encode_6bits` function per-encoding.
diff --git a/base64ct/src/encoder.rs b/base64ct/src/encoder.rs index 0f9e111..4dfbf73 100644 --- a/base64ct/src/encoder.rs +++ b/base64ct/src/encoder.rs @@ -37,12 +37,15 @@ const fn encoded_len_inner(n: usize, padded: bool) -> Option<usize> { /// Encode the input byte slice as Base64, writing the result into the provi...
6
170
148
d95ecee6e06e49780d0b4130bcca83be47abd44e
Tony Arcieri
2021-01-31T15:58:54
base64ct: refactor into modules (#235) Refactors the single-file `lib.rs` implementation into separate modules for encoding/decoding and specific "flavors" of Base64. This is in preparation for adding another new Base64 flavor (the "libcrypt" flavor used by bcrypt and SHA-crypt password hashes)
diff --git a/base64ct/src/decoder.rs b/base64ct/src/decoder.rs new file mode 100644 index 0000000..42220c2 --- /dev/null +++ b/base64ct/src/decoder.rs @@ -0,0 +1,234 @@ +//! Base64 decoder. + +use crate::{Error, InvalidEncodingError, PAD}; +use core::ops::Range; + +#[cfg(feature = "alloc")] +use alloc::vec::Vec; + +///...
6
609
600
9ac53c1f151872b9fff24f8b47e19892f045b748
Артём Павлов [Artyom Pavlov]
2021-01-28T20:54:58
release block-buffer v0.10.0-pre.1
diff --git a/Cargo.lock b/Cargo.lock index 7d41ca1..cefb610 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,7 +13,7 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.0-pre" +version = "0.10.0-pre.1" dependencies = [ "block-padding", "generic-array", diff --git a/block-buffer/Cargo.toml b/b...
2
2
2
a3ea2a369bfc0b0a9a7dff4570f69a861fd48c4c
Tony Arcieri
2021-01-26T04:54:17
base64ct: refactor decoders and encoders (#230)
diff --git a/base64ct/src/lib.rs b/base64ct/src/lib.rs index 2699ba8..3a4218e 100644 --- a/base64ct/src/lib.rs +++ b/base64ct/src/lib.rs @@ -35,7 +35,7 @@ mod errors; pub use errors::{Error, InvalidEncodingError, InvalidLengthError}; -use core::str; +use core::{ops::Range, str}; #[cfg(feature = "alloc")] use a...
1
29
21
d6f947f2b7db5fd01195349e36a241a611daddb2
Tony Arcieri
2021-01-25T21:49:31
base64ct: cleanups (#228) This commit contains a number of small improvements: - Removes the remaining data-dependent branches - Fixes overflow in padded `decoded_len` calculation - Replaces use of `isize` with `i16` (the specific needed type) - Extracts methods for constant-time pseudo-branch operations
diff --git a/base64ct/src/lib.rs b/base64ct/src/lib.rs index 55f05f2..2096d5f 100644 --- a/base64ct/src/lib.rs +++ b/base64ct/src/lib.rs @@ -146,7 +146,7 @@ pub fn decode<'a>(src: &str, dst: &'a mut [u8], padded: bool) -> Result<&'a [u8] } let src = src.as_bytes(); let dst = &mut dst[..dlen]; - let mu...
1
72
60
5674b8d6144f071b77d33bf2e57b725c5653c678
Tony Arcieri
2021-01-25T19:41:42
base64ct: add decode_in_place support for padded Base64 (#227) Previously it was specialized to only unpadded Base64. Also unifies the padded and unpadded tests, now that they share implementation parity.
diff --git a/base64ct/src/lib.rs b/base64ct/src/lib.rs index d5e2cef..55f05f2 100644 --- a/base64ct/src/lib.rs +++ b/base64ct/src/lib.rs @@ -45,6 +45,7 @@ const PAD: u8 = b'='; /// Encode the input byte slice as Base64, writing the result into the provided /// destination slice, and returning an ASCII-encoded strin...
4
231
251
941e37976dfcaf378e0cd1c9a6baf77185c1e38a
Tony Arcieri
2021-01-24T00:36:03
base64ct: support both unpadded and padded encodings (#225) We need support for both: - "PEM" (as used by PKCS#8) needs padded Base64 - "B64" (as used by the PHC string format) and JWK need unpadded Base64
diff --git a/base64ct/src/errors.rs b/base64ct/src/errors.rs index 2f33f60..8533fc2 100644 --- a/base64ct/src/errors.rs +++ b/base64ct/src/errors.rs @@ -1,3 +1,5 @@ +//! Error types + use core::fmt; /// Insufficient output buffer length. diff --git a/base64ct/src/lib.rs b/base64ct/src/lib.rs index 4e1a216..d5e2cef ...
5
254
88
70167987c2c27872320bce17e429312d02d73fda
Tony Arcieri
2021-01-22T20:14:35
base64ct: fixups (#223) Fix version number and description
diff --git a/Cargo.lock b/Cargo.lock index 6a2100e..cdad641 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "base64ct" -version = "0.2.0" +version = "0.0.0" [[package]] name = "blobby" diff --git a/base64ct/Cargo.toml b/base64ct/Cargo.toml inde...
3
5
6
b2b5fb554fad25071f4268bc6e8fb3d6def4bc7e
Tony Arcieri
2021-01-22T01:55:16
der: add integer decoder helper methods (#219) Adds a set of inherent methods to `Decoder` to assist in decoding ASN.1 `INTEGER` values: - `int8` - `int16` - `uint8` - `uint16` - `big_uint`
diff --git a/der/src/decoder.rs b/der/src/decoder.rs index c3ce6c1..48d7013 100644 --- a/der/src/decoder.rs +++ b/der/src/decoder.rs @@ -3,6 +3,9 @@ use crate::{Any, BitString, Decodable, ErrorKind, Length, Null, OctetString, Result, Sequence}; use core::convert::TryInto; +#[cfg(feature = "big-uint")] +use crate::{...
1
34
0
39ef46c61f4658e9dc2a4cd91aa7cda0f8397adc
Artyom Pavlov
2021-01-20T10:31:46
block-buffer: mark digest_pad as public
diff --git a/block-buffer/src/lib.rs b/block-buffer/src/lib.rs index 6a2a120..f30c68a 100644 --- a/block-buffer/src/lib.rs +++ b/block-buffer/src/lib.rs @@ -174,7 +174,7 @@ impl<BlockSize: ArrayLength<u8>> BlockBuffer<BlockSize> { /// the `suffix` bytes. If there is not enough unused space, `compress` /// wil...
1
1
1
fc2cddfc7aaa6023184740068277bc0cc9b9a1ff
Tony Arcieri
2021-01-20T02:11:15
der: doc fixups (#218)
diff --git a/der/Cargo.toml b/der/Cargo.toml index 2dceac8..b1577ab 100644 --- a/der/Cargo.toml +++ b/der/Cargo.toml @@ -2,13 +2,13 @@ name = "der" version = "0.2.0-pre" # Also update html_root_url in lib.rs when bumping this description = """ -Pure Rust embedded-friendly implementation of the Distinguished Encoding...
1
3
3
57af3287d79642a558e7003f7522fa382231d582
Tony Arcieri
2021-01-20T01:36:43
b64ct: documentation improvements (#216)
diff --git a/b64ct/src/lib.rs b/b64ct/src/lib.rs index 7efeb6c..01d4035 100644 --- a/b64ct/src/lib.rs +++ b/b64ct/src/lib.rs @@ -1,21 +1,67 @@ //! Pure Rust implementation of "B64" encoding, a minified subset of the standard -//! Base64 encoding (RFC 4648, section 4) used by the PHC string format. +//! Base64 encoding...
1
53
7
cbe6d4e796f0da01943c3a58dc015d2a2a03e783
Artyom Pavlov
2021-01-19T10:41:28
dbl: fix unsoundness (#214)
diff --git a/Cargo.lock b/Cargo.lock index b8771bd..564578c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ version = "0.2.0" [[package]] name = "dbl" -version = "0.3.0" +version = "0.3.1" dependencies = [ "generic-array", ] diff --git a/dbl/Cargo.toml b/dbl/Cargo.toml index 1ca7d48..2655841 100644 -...
3
10
10
fa2ae53ead5dd6a28c86997b885f5c65f0769a7c
Artyom Pavlov
2021-01-19T10:32:31
Use SVG logo and html_root_url in all crates (#213)
diff --git a/b64ct/Cargo.toml b/b64ct/Cargo.toml index f923367..f73eb77 100644 --- a/b64ct/Cargo.toml +++ b/b64ct/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "b64ct" -version = "0.1.0" +version = "0.1.0" # Also update html_root_url in lib.rs when bumping this description = """ Pure Rust implementation of B64, a sub...
21
51
18
5c174b500f50dac9cf2376dac2bbf6ac05560b6f
Tony Arcieri
2021-01-13T20:20:06
der: u8 and u16 support (#210) Support for encoding/decoding unsigned ASN.1 INTEGER values to/from these Rust primitive types.
diff --git a/der/src/asn1/integer.rs b/der/src/asn1/integer.rs index f8ed387..faa57cb 100644 --- a/der/src/asn1/integer.rs +++ b/der/src/asn1/integer.rs @@ -1,10 +1,14 @@ //! ASN.1 `INTEGER` support. -// TODO(tarcieri): add support for `i32`, `u8`, `u16`, `u32`, etc. +// TODO(tarcieri): add support for `i32`/`u32` ...
3
171
21
b3c6e260605e7dbf0e1c65589fcf1a648a9ad8d3
Artyom Pavlov
2021-01-13T20:06:46
Modify decode_in_place to be panic-free (#209)
diff --git a/b64ct/src/lib.rs b/b64ct/src/lib.rs index 6ac62cd..e38227b 100644 --- a/b64ct/src/lib.rs +++ b/b64ct/src/lib.rs @@ -125,17 +125,26 @@ pub fn decode<'a>(src: &str, dst: &'a mut [u8]) -> Result<&'a [u8], Error> { /// Decode B64-encoded string in-place. pub fn decode_in_place(buf: &mut [u8]) -> Result<&[u...
1
33
10
6aa7184be33f98864341d7c99880ac0fcab4cec1
Tony Arcieri
2021-01-13T18:50:16
der: fix unsigned INTEGER handling; more test vectors (#208) Fixes a bug in leading `0` handling for unsigned integers (needed if the second octet is >=0x80)
diff --git a/der/src/asn1/big_uint.rs b/der/src/asn1/big_uint.rs index 3b23706..29e657f 100644 --- a/der/src/asn1/big_uint.rs +++ b/der/src/asn1/big_uint.rs @@ -197,38 +197,53 @@ impl_size!( #[cfg(test)] mod tests { use super::BigUInt; - use crate::{Any, ErrorKind, Result, Tag}; + use crate::{asn1::integer...
2
72
80
84164682315235af0b3f73a7805c8c9c37e0f2fc
Artyom Pavlov
2021-01-13T13:21:41
Add decode_in_place and benchmarks to b64ct (#206)
diff --git a/b64ct/benches/mod.rs b/b64ct/benches/mod.rs new file mode 100644 index 0000000..f9273b7 --- /dev/null +++ b/b64ct/benches/mod.rs @@ -0,0 +1,58 @@ +#![feature(test)] +extern crate test; +use test::Bencher; + +const B64_LEN: usize = 100_002; +const RAW_LEN: usize = (3 * B64_LEN) / 4; + +#[inline(never)] +fn ...
3
108
3
811883a224b9cd24923d38cb8bd78915a5272dea
Artyom Pavlov
2021-01-12T23:07:25
Rustified panic-free modification of b64ct (#204)
diff --git a/b64ct/src/errors.rs b/b64ct/src/errors.rs new file mode 100644 index 0000000..2f33f60 --- /dev/null +++ b/b64ct/src/errors.rs @@ -0,0 +1,63 @@ +use core::fmt; + +/// Insufficient output buffer length. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct InvalidLengthError; + +impl fmt::Display for Inv...
3
218
211
f2f49861a1edfb72523709af108a99feb6f18a67
Tony Arcieri
2021-01-12T20:59:32
der: export `BigUIntSize` (#203) This is needed for trait bounds.
diff --git a/der/src/asn1/big_uint.rs b/der/src/asn1/big_uint.rs index df318a1..3b23706 100644 --- a/der/src/asn1/big_uint.rs +++ b/der/src/asn1/big_uint.rs @@ -20,7 +20,7 @@ use typenum::Unsigned; /// Currently supported sizes are 1 - 512 bytes. #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[cfg_attr(docsrs, doc(cf...
2
14
10
21fe44f750178e027241e09d378e147428755f7a
Tony Arcieri
2021-01-12T16:32:26
der: i16 support (#199) Adds basic support for encoding/decoding signed 16-bit integers.
diff --git a/der/src/asn1/integer.rs b/der/src/asn1/integer.rs index c7d9574..161644a 100644 --- a/der/src/asn1/integer.rs +++ b/der/src/asn1/integer.rs @@ -1,5 +1,7 @@ //! ASN.1 `INTEGER` support. +// TODO(tarcieri): add support for `i32`, `u8`, `u16`, `u32`, etc. + use crate::{Any, Encodable, Encoder, Error, Erro...
2
125
8
ad9ffd9cad2dcbb4e019f6c5c2dccf2763cf7a02
Tony Arcieri
2021-01-12T15:35:16
der: expand allowed BigUInt sizes; additional comments (#198) Allows parsing of `BigUInt` values up to 512-bytes long. This corresponds to 4096-bits and should be sufficient for practical cryptographic purposes (at least for now).
diff --git a/der/src/asn1/big_uint.rs b/der/src/asn1/big_uint.rs index 44200a4..df318a1 100644 --- a/der/src/asn1/big_uint.rs +++ b/der/src/asn1/big_uint.rs @@ -8,14 +8,16 @@ use typenum::Unsigned; /// "Big" unsigned ASN.1 `INTEGER` type. /// -/// Provides direct access to the underlying bytes which comprise an uns...
1
43
13
b4abf2a701e2209f83f3b61509918be51562b5b7
Tony Arcieri
2021-01-12T06:08:12
der: rename `big_uint` module (#197) From `big_integer` previously.
diff --git a/der/src/asn1.rs b/der/src/asn1.rs index 0ac548e..f05e082 100644 --- a/der/src/asn1.rs +++ b/der/src/asn1.rs @@ -4,7 +4,7 @@ pub(crate) mod any; #[cfg(feature = "big-uint")] -pub(crate) mod big_integer; +pub(crate) mod big_uint; pub(crate) mod bit_string; pub(crate) mod boolean; pub(crate) mod intege...
3
2
2
2064faf0752acbb375f1f1c92790f04dfb32cf98
Tony Arcieri
2021-01-11T01:09:55
pkcs8 v0.4.0-pre (#195)
diff --git a/Cargo.lock b/Cargo.lock index 84f4e70..52f9401 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,7 +88,7 @@ version = "0.3.0" [[package]] name = "pkcs8" -version = "0.3.3" +version = "0.4.0-pre" dependencies = [ "der", "hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff...
3
3
3
745a20935cacad4b9ce379f3d606d6a6c57eaca8
Tony Arcieri
2021-01-11T01:05:17
der v0.2.0-pre (#194)
diff --git a/Cargo.lock b/Cargo.lock index be24ed7..84f4e70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "der" -version = "0.1.0" +version = "0.2.0-pre" dependencies = [ "const-oid", "der_derive", diff --git a/der/Cargo.toml b/der/Cargo.toml index 41c3996..3bce...
4
4
4
d10f6521fe6654f2c0d09740cfb4130808b0a74c
Tony Arcieri
2021-01-11T00:58:58
der: handle leading byte of BIT STRINGs (#193) The first octet of a BIT STRING encodes the number of unused bits. Previous versions of this crate trated this octet as a verbatim part of the bit string rather than decoding/encoding it. This commit changes that behavior, presently ensuring the value is 0 (i.e. n...
diff --git a/der/src/asn1/bit_string.rs b/der/src/asn1/bit_string.rs index 83db443..19c09c8 100644 --- a/der/src/asn1/bit_string.rs +++ b/der/src/asn1/bit_string.rs @@ -1,6 +1,8 @@ //! ASN.1 `BIT STRING` support. -use crate::{Any, ByteSlice, Encodable, Encoder, Error, ErrorKind, Length, Result, Tag, Tagged}; +use cr...
3
75
8
005b32230010de490fc75d6ca6e58dd8b0c90837
Tony Arcieri
2020-12-22T04:13:28
der: add `Length::to_usize` (#184) Adds an inherent method for converting `Length` to `usize`.
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index b2b5974..5580d13 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -92,7 +92,7 @@ impl<'a> Decodable<'a> for Any<'a> { fn decode(decoder: &mut Decoder<'a>) -> Result<Any<'a>> { let header = Header::decode(decoder)?; let tag ...
5
19
6
bda3f7e1a1885178595e0b4a14b9d757cf99b297
Tony Arcieri
2020-12-22T03:53:55
der: make `sequence` module public (#183) Provides access to `der::sequence::encoded_len`, which is helpful for lower-level use cases.
diff --git a/der/src/asn1.rs b/der/src/asn1.rs index b96cea9..816fa39 100644 --- a/der/src/asn1.rs +++ b/der/src/asn1.rs @@ -11,4 +11,4 @@ pub(crate) mod octet_string; #[cfg(feature = "oid")] pub(crate) mod oid; pub(crate) mod optional; -pub(crate) mod sequence; +pub mod sequence; diff --git a/der/src/asn1/sequence....
3
8
4
966d80d413839616bf14fb8065b220c4275e447c
Tony Arcieri
2020-12-22T03:30:47
pkcs8: activate `der/std` (#182) Since it's re-exported, even though the `pkcs8` crate doesn't use it, it's nice to activate the feature anyway just in case downstream users of the `der` crate want it.
diff --git a/pkcs8/Cargo.toml b/pkcs8/Cargo.toml index 62a2f40..503769b 100644 --- a/pkcs8/Cargo.toml +++ b/pkcs8/Cargo.toml @@ -37,7 +37,7 @@ hex-literal = "0.3" [features] alloc = ["der/alloc", "zeroize"] pem = ["alloc", "subtle-encoding"] -std = ["alloc"] +std = ["alloc", "der/std"] [package.metadata.docs.rs] ...
1
1
1
022007f591e92bfb14a16bd3192309d398d2f2f0
Tony Arcieri
2020-12-22T02:11:08
der: add support for context-specific types (#181) Context-specific types are specific to a particular structure. They're needed to properly implement PKCS#8 decoding.
diff --git a/der/src/tag.rs b/der/src/tag.rs index 1641e25..cfbde76 100644 --- a/der/src/tag.rs +++ b/der/src/tag.rs @@ -3,9 +3,17 @@ use crate::{Decodable, Decoder, Encodable, Encoder, Error, ErrorKind, Length, Result}; use core::{convert::TryFrom, fmt}; +/// Indicator bit for constructed form encoding (i.e. vs pr...
1
29
2
be265dbcc52ff645ba3f9a1c46b5f52505b279af
Tony Arcieri
2020-12-22T01:15:59
pkcs8: re-export the `der` crate (#180) PKCS#8 decoders/encoders need custom DER format support in order to parse the contents of private and public key fields. Re-exporting the version of the `der` crate used by `pkcs8` allows them to easily access this while still gating the functionality on the crate-as-a-fea...
diff --git a/pkcs8/src/lib.rs b/pkcs8/src/lib.rs index ed4120d..2480c9e 100644 --- a/pkcs8/src/lib.rs +++ b/pkcs8/src/lib.rs @@ -73,7 +73,7 @@ pub use crate::{ spki::SubjectPublicKeyInfo, traits::{FromPrivateKey, FromPublicKey}, }; -pub use der::ObjectIdentifier; +pub use der::{self, ObjectIdentifier}; #[...
1
1
1
656d88f98632ca52e8f5b29b82e1efd33b28a69c
Tony Arcieri
2020-12-21T23:58:58
der: #[asn1(type = "...")] custom derive attribute (#179) Adds a field attribute for providing a type hint when decoding/encoding messages. This can be used to implement intermediate conversions, e.g. in the event a field doesn't directly implement `Decodable` and `Encodable`.
diff --git a/der/derive/src/lib.rs b/der/derive/src/lib.rs index 710a215..21c4be7 100644 --- a/der/derive/src/lib.rs +++ b/der/derive/src/lib.rs @@ -5,17 +5,32 @@ use proc_macro2::TokenStream; use quote::{quote, ToTokens}; -use syn::{DataStruct, Field, Generics, Ident, Lifetime}; +use syn::{ + DataStruct, Field,...
3
183
46
cf75cddbef22f928fc46ea816d5cf789aad46edf
Tony Arcieri
2020-12-21T19:02:30
der: extract `Sequence::decode_nested` (#177) DRYs out the parsing of fields nested in `Sequence` data into a new `Sequence::decode_nested` method.
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index 29a0969..b2b5974 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -74,9 +74,9 @@ impl<'a> Any<'a> { /// nested [`Decoder`] and calling the provided argument with it. pub fn sequence<F, T>(self, f: F) -> Result<T> where - F: ...
6
20
19
20a2cf4898890f27014b4903061675721c66a947
Tony Arcieri
2020-12-21T17:27:37
pkcs8: use DER encoding helpers (#176) Gets rid of some redundant boilerplate
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 6690ca3..21cad9b 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -30,9 +30,7 @@ pub struct AlgorithmIdentifier { impl AlgorithmIdentifier { /// Parse [`AlgorithmIdentifier`] encoded as ASN.1 DER pub fn from_der(bytes: &[u8...
3
6
18
0111f94a39961e7d8e00c680d0bf0a96dd9f0aa1
Tony Arcieri
2020-12-21T16:50:59
der: have `Decoder::sequence` call `::finish` automatically (#174) ...on the nested decoder it creates. This changes the API to have the `FnOnce` callback for decoding a sequence borrow the decoder rather than passing it by value. This allows the caller function to retain ownership, and with that it can call f...
diff --git a/der/src/decoder.rs b/der/src/decoder.rs index 9fcd5d0..f2514f1 100644 --- a/der/src/decoder.rs +++ b/der/src/decoder.rs @@ -112,13 +112,17 @@ impl<'a> Decoder<'a> { /// [`Decoder`] and calling the provided argument with it. pub fn sequence<F, T>(&mut self, f: F) -> Result<T> where - F...
4
14
11
5c4a8589096c17cc52de817fea52c079a922f440
Tony Arcieri
2020-12-21T16:35:23
der: assorted tests (#171) Adds some basic tests for encoding/decoding, including ones for various ASN.1 types and the `Decoder` and `Encoder` types themselves.
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index 692b486..29a0969 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -1,8 +1,8 @@ //! ASN.1 `ANY` type. use crate::{ - BitString, ByteSlice, Decodable, Decoder, Encodable, Encoder, Error, ErrorKind, Header, - Integer, Length, Null, OctetSt...
12
307
119
d22395127fac4990477c8cdb9f89b09c21fb86c1
Tony Arcieri
2020-12-21T16:30:59
const-oid: fix bug in const initializer (#172) One of the lengths (4) was mishandled, which prevented code from compiling when used in a const context.
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index 0e72920..230aa97 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -176,7 +176,7 @@ impl ObjectIdentifier { 0, 0, 0, 0, 0 ], 4 => [ - arcs[2], arcs[3], arcs[4], 0, 0, + a...
1
1
1
7b0c2d8171ca38c8568bba41807ae3e39a4ac55b
Tony Arcieri
2020-12-21T14:32:43
der: add comments about SEQUENCE tags (#170)
diff --git a/der/src/tag.rs b/der/src/tag.rs index 3e637bb..e1c6cb2 100644 --- a/der/src/tag.rs +++ b/der/src/tag.rs @@ -26,6 +26,10 @@ pub enum Tag { ObjectIdentifier = 0x06, /// `SEQUENCE` tag. + /// + /// Note that the universal tag number for `SEQUENCE` is technically `0x10` + /// however we pr...
1
4
0
e263493bfeaf49a9021bd95c2861ae9ccd88b5d8
Tony Arcieri
2020-12-20T21:06:20
der: add `RawInteger` type (#169) Adds a type which provides raw access to the underlying bytes of an ASN.1 INTEGER which can be used for decoding/encoding "big integer" types such as cryptographic keys. Note that this implementation does not ensure that the encoding of such integers is canonical. For now it's d...
diff --git a/der/src/asn1/bit_string.rs b/der/src/asn1/bit_string.rs index 141eb18..83db443 100644 --- a/der/src/asn1/bit_string.rs +++ b/der/src/asn1/bit_string.rs @@ -11,14 +11,14 @@ pub struct BitString<'a> { } impl<'a> BitString<'a> { - /// Create a new [`BitString`] from a slice + /// Create a new [`BitS...
4
120
26
75811c5aaf18170ee6ade594467e451f2e4d3a49
Tony Arcieri
2020-12-20T20:20:05
der: add "Usage" section to rustdoc (#168) Adds a heavily-commented code example for how to define, encode, and decode ASN.1 DER messages.
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index f303aeb..692b486 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -1,8 +1,8 @@ //! ASN.1 `ANY` type. use crate::{ - BitString, ByteSlice, Decodable, Decoder, Encodable, Encoder, ErrorKind, Header, Integer, - Length, Null, OctetString, R...
6
219
8
420d13e7b9232eba3984c5a71bc73c9949eeaab5
Tony Arcieri
2020-12-20T18:10:53
der: error handling improvements (#167) Renames the previous `Error` enum to `ErrorKind`, and adds an `Error` struct with a `::kind()` method as well as an optional position where the error occurred to assist in debugging. Also adds a proper `Display` impl to `ErrorKind` with messages about each of the variants.
diff --git a/der/src/asn1/any.rs b/der/src/asn1/any.rs index 43ff0da..f303aeb 100644 --- a/der/src/asn1/any.rs +++ b/der/src/asn1/any.rs @@ -1,8 +1,8 @@ //! ASN.1 `ANY` type. use crate::{ - BitString, ByteSlice, Decodable, Decoder, Encodable, Encoder, Error, Header, Integer, Length, - Null, OctetString, Resul...
18
340
116
5314d6dc689a8774b83935bde1a889132065e3c0
Tony Arcieri
2020-12-19T13:40:30
der: bound `Message` on `Decodable` (#166) Unfortunately this adds the `Decodable` lifetime to `Message`, but I'm not sure there's much that can be done about that.
diff --git a/der/src/traits.rs b/der/src/traits.rs index d980422..00ac701 100644 --- a/der/src/traits.rs +++ b/der/src/traits.rs @@ -78,7 +78,7 @@ pub trait Tagged { /// Types which impl this trait receive blanket impls for the [`Decodable`], /// [`Encodable`], and [`Tagged`] traits. // TODO(tarcieri): ensure all `M...
4
12
6
df59d70a529fcb348d5a6610fcea477fdcc6c826
Tony Arcieri
2020-12-19T04:28:08
der: `Debug` and `Display` impls for `Tag` (#165) Adds `Display` impl with upper case type names (e.g. "OBJECT IDENTIFIER") and a `Debug` impl with the hex octet and the type name: Tag(0x06: OBJECT IDENTIFIER)
diff --git a/der/src/byte_slice.rs b/der/src/byte_slice.rs index d69e22d..a995f53 100644 --- a/der/src/byte_slice.rs +++ b/der/src/byte_slice.rs @@ -20,10 +20,9 @@ impl<'a> ByteSlice<'a> { /// Create a new [`ByteSlice`], ensuring that the provided `slice` value /// is shorter than `Length::max()`. pub fn...
2
41
17
996d0cb176e0d61ede10bca9d196fe6faa3ee231
Tony Arcieri
2020-12-19T04:09:25
der: add `Boolean` type (#164) Adds support for the ASN.1 `BOOLEAN` type.
diff --git a/der/src/asn1.rs b/der/src/asn1.rs index 93ea7f0..b96cea9 100644 --- a/der/src/asn1.rs +++ b/der/src/asn1.rs @@ -4,6 +4,7 @@ pub(crate) mod any; pub(crate) mod bit_string; +pub(crate) mod boolean; pub(crate) mod integer; pub(crate) mod null; pub(crate) mod octet_string; diff --git a/der/src/asn1/bool...
4
75
6
a2bd4679fe876c9683d35b4c4fb863c985005996
Tony Arcieri
2020-12-19T03:41:51
der: fix link in Cargo.toml
diff --git a/der/Cargo.toml b/der/Cargo.toml index a55a5ab..6accc23 100644 --- a/der/Cargo.toml +++ b/der/Cargo.toml @@ -9,7 +9,7 @@ authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" edition = "2018" documentation = "https://docs.rs/pkcs8" -repository = "https://github.com/RustCrypto/utils/tree/maste...
1
1
1
66f19f57289a219205984d346ddfc908f04277ee
Tony Arcieri
2020-12-19T03:38:51
der: extract `sequence::encoded_len_inner()` (#163) DRYs out computing the length of the inner body of a SEQUENCE (sans tag and length prefix) into a single function.
diff --git a/der/src/asn1/sequence.rs b/der/src/asn1/sequence.rs index 39bfc16..e9093e6 100644 --- a/der/src/asn1/sequence.rs +++ b/der/src/asn1/sequence.rs @@ -6,15 +6,20 @@ use crate::{ use core::convert::TryFrom; /// Obtain the length of an ASN.1 `SEQUENCE` of [`Encodable`] values when -/// serialized as ASN.1 D...
2
15
12
f73a402c7cb1edf41dc3e123f750ba638fbaba1c
Tony Arcieri
2020-12-19T03:32:05
der: extract `asn1` module (#162) Extracts ASN.1 built-in types into their own module.
diff --git a/der/src/asn1.rs b/der/src/asn1.rs new file mode 100644 index 0000000..93ea7f0 --- /dev/null +++ b/der/src/asn1.rs @@ -0,0 +1,13 @@ +//! ASN.1 types. +//! +//! Includes built-in ASN.1 types and helper types for modeling ASN.1 concepts. + +pub(crate) mod any; +pub(crate) mod bit_string; +pub(crate) mod integ...
12
30
24
ed9fe8737a791c6738ac2ff9f62083eae111612b
Tony Arcieri
2020-12-19T03:22:39
der: extract `ByteSlice` type (#161) Adds a newtype for byteslices that provides a central place to check the `Length::max()` invariant inforced by this library. Uses this newly introduced type to impl `Any`, `BitString`, `OctetString`, and `Sequence`. This eliminates the last of the `Result::expect` calls in ...
diff --git a/der/src/any.rs b/der/src/any.rs index cf45e2e..43ff0da 100644 --- a/der/src/any.rs +++ b/der/src/any.rs @@ -1,7 +1,7 @@ //! ASN.1 `ANY` type. use crate::{ - length, BitString, Decodable, Decoder, Encodable, Encoder, Error, Header, Integer, Length, + BitString, ByteSlice, Decodable, Decoder, Encod...
15
127
77
e0ce2ba6882280fe6f0180d3935f5a5f013bcf4a
Tony Arcieri
2020-12-19T02:13:11
der: use `Length` as the position cursor for `Decoder`/`Encoder` (#160) The `Length` type provides checked arithmetic with overflow handling and simple conversions to `usize`. This simplifies the previously verbose boilerplate for doing checked arithmetic using `checked_add`, and also encapsulates values such tha...
diff --git a/der/src/decoder.rs b/der/src/decoder.rs index b239a0e..ce1ebba 100644 --- a/der/src/decoder.rs +++ b/der/src/decoder.rs @@ -1,7 +1,7 @@ //! ASN.1 DER decoder. use crate::{ - Any, BitString, Decodable, Error, Integer, Null, OctetString, Result, Sequence, Tagged, + Any, BitString, Decodable, Error,...
2
26
21
867f3e157e870928ab38a85fb2963b9435ecfafe
Tony Arcieri
2020-12-18T06:43:01
der: `Decoder` struct (#158) Adds a struct for wrapping a slice that's in the process of being decoded, along with ample helper methods for various types which simplify writing decoders.
diff --git a/der/src/any.rs b/der/src/any.rs index 01f0d63..78ffdb5 100644 --- a/der/src/any.rs +++ b/der/src/any.rs @@ -1,6 +1,13 @@ //! ASN.1 `ANY` type -use crate::{Decodable, Decoder, Error, Header, Length, Result, Tag}; +use crate::{ + BitString, Decodable, Decoder, Error, Header, Integer, Length, Null, Octe...
9
239
113
fd54c9070605948d09cade5ed1fe53a4f3fad9c8
Tony Arcieri
2020-12-18T05:24:58
der: `Decodable` trait and core types (#157) Refactors the decoder using a trait-based approach, centered around a `Decodable` trait which operates over the initial extraction of a `Decoder` type. Adds structs for representing the ASN.1 core types we support, and then impls the `Decodable` trait on those types. ...
diff --git a/der/Cargo.toml b/der/Cargo.toml index df28b28..3f383fe 100644 --- a/der/Cargo.toml +++ b/der/Cargo.toml @@ -14,13 +14,13 @@ categories = ["cryptography", "data-structures", "encoding", "no-std"] keywords = ["asn1", "crypto", "itu", "pkcs"] readme = "README.md" -[dependencies.oid] -package = "const-oid"...
21
604
230
2d171dbbf1f25f972a7fd3727beb867fcd1a783b
Tony Arcieri
2020-12-18T00:00:43
der: support for decoding `OPTIONAL` fields (#156) Also uses the new support to simplify the `AlgorithmParameters` decoder.
diff --git a/der/src/decode.rs b/der/src/decode.rs index 138dd67..bf31ccf 100644 --- a/der/src/decode.rs +++ b/der/src/decode.rs @@ -33,11 +33,9 @@ pub fn integer(bytes: &mut &[u8]) -> Result<usize> { } } -/// Decode nested value (e.g. `OCTET STRING`, `SEQUENCE`). -/// -/// This function provides a panic-free f...
2
47
61
2de5f1ca6c672c0bdd2e6a62e297747052291f07
Tony Arcieri
2020-12-17T23:12:07
der: refactor decoder using lambdas (#155) Adds a lambda argument to the `nested` function, having it perform TLV decoding and yielding the decoded tag and value to the lambda. Also adds a set of new functions for parsing fields with expected tags, including a general purpose `tagged` for expecting a particular t...
diff --git a/der/src/decode.rs b/der/src/decode.rs index dc1c618..138dd67 100644 --- a/der/src/decode.rs +++ b/der/src/decode.rs @@ -1,22 +1,67 @@ //! ASN.1 DER decoding support. use crate::{Error, Result, Tag}; +use core::convert::TryFrom; #[cfg(feature = "oid")] use crate::ObjectIdentifier; +/// Extract the...
8
244
128
809d1cea25f1d8c7f904d505eafa87a1803873db
Tony Arcieri
2020-12-17T20:46:55
der: extract `length` module (#154) Small cleanup and consistency improvement. It may be possible to eliminate this module in the future, or it might make sense to make it the one place for all length-related functionality which could be useful. For now, it gets this code out of the way to permit more refactor...
diff --git a/der/src/encode.rs b/der/src/encode.rs index 7adb08c..0d21970 100644 --- a/der/src/encode.rs +++ b/der/src/encode.rs @@ -5,18 +5,6 @@ use crate::{Error, Result, Tag}; #[cfg(feature = "oid")] use crate::ObjectIdentifier; -/// Compute the length of a header including the tag byte. -/// -/// This function ...
6
37
30
d7ae8aaa3e8db47a45c1fc7a31157dc905e09c90
Tony Arcieri
2020-12-17T01:39:17
pkcs8: simplify implementation of AlgorithmIdentifier::parameters_oid (#151)
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 9726876..9b727b9 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -39,10 +39,7 @@ impl AlgorithmIdentifier { /// /// Returns `None` if it is absent or not an OID. pub fn parameters_oid(&self) -> Option<ObjectIdentifier>...
1
1
4
2d07c334f67418cfe9e63ffb04092ddd4a14cb21
Tony Arcieri
2020-12-17T01:16:08
const-oid: doc improvements (#150)
diff --git a/const-oid/Cargo.toml b/const-oid/Cargo.toml index c1c347f..55b7172 100644 --- a/const-oid/Cargo.toml +++ b/const-oid/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" description = """ Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard as defined in ITU X.660, with support for BER/D...
3
13
8
76ed73557ab1e92812b73b51c11192687280aac5
Tony Arcieri
2020-12-17T00:56:00
pkcs8: add `AlgorithmIdentifier::parameters_oid` (#148) Adds a convenience method to retrieve the `parameters` of an `AlgorithmIdentifier` as an `ObjectIdentifier` without having to match on the intermediate `AlgorithmParameters` enum.
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 6842a89..9726876 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -35,6 +35,16 @@ impl AlgorithmIdentifier { } } + /// Get the `parameters` field as an [`ObjectIdentifier`]. + /// + /// Returns `None` if it is...
1
10
0
67c06392b4bfc9f9a6c1c2c6ccbf057ac2487605
Tony Arcieri
2020-12-17T00:39:07
pkcs8: documentation tweaks (#147)
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index ebcd99f..6842a89 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -15,16 +15,11 @@ use core::convert::TryFrom; /// ``` #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct AlgorithmIdentifier { - /// Algorithm OID. - /// -...
1
4
9
cd5b8e509f2590a369763f20daaef6b3308ba55a
Tony Arcieri
2020-12-16T20:30:59
const-oid: refactor and improve arc length limits (#144) Adds documentation for arc length limits (3..=12) along with a `MIN_LENGTH` constant, which is used throughout the implementation now. Also adds additional tests and fixes a big with parsing underlength OIDs from strings.
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index 9946887..83f93f3 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -18,6 +18,14 @@ //! //! For more information, see: <https://en.wikipedia.org/wiki/Object_identifier> //! +//! # Limits +//! +//! This library stores OIDs using a compact fix...
1
39
22
ee1365266d23fc292ebb411ac0cd728049b2aaa4
Tony Arcieri
2020-12-16T20:04:43
const-oid: layout optimization (#143) Stores the first two arcs of an OID as a `u8`, rather than `[u32; 2]`. The range of values of these nodes is constrained such that this is possible. The ASN.1 DER encoding takes advantage of this optimization. With this change, it's possible to store an additional two arcs ...
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index c874d91..9946887 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -43,13 +43,24 @@ extern crate alloc; #[cfg(any(feature = "std", test))] extern crate std; -use core::{convert::TryFrom, fmt, str::FromStr}; +use core::{ + convert::TryFr...
1
225
91
5f07e3abc506e036d0506e2a9dcdbf3791ec1ef7
Tony Arcieri
2020-12-16T16:31:20
const-oid: rename nodes to arcs (#142) X.660 uses the term "arc" to describe the components of an OID. This commit renames "nodes" (which is more of an informal term) to "arcs" to reflect this.
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index 5d30778..c874d91 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -45,16 +45,17 @@ extern crate std; use core::{convert::TryFrom, fmt, str::FromStr}; -/// Maximum number of nodes in an OID. +/// Maximum number of arcs in an OID. /// -//...
1
91
91
5f73bdcbf9ad08417af9bea3792c1925a93d950e
Tony Arcieri
2020-12-16T15:29:57
const-oid: add `Nodes` iterator (#141) Replaces the previous `AsRef<[u32]>` impl on `ObjectIdentifier` with an iterator type: `Nodes`. This allows for using a more compact internal representation for the `ObjectIdentifier` struct, because it no longer requires that the first two nodes are represented as u32 (the...
diff --git a/const-oid/src/lib.rs b/const-oid/src/lib.rs index bd53241..5d30778 100644 --- a/const-oid/src/lib.rs +++ b/const-oid/src/lib.rs @@ -91,6 +91,7 @@ macro_rules! const_assert { }; } +#[allow(clippy::len_without_is_empty)] impl ObjectIdentifier { /// Create an OID from a slice of integers. /...
1
45
10
5a7cd5c8ed89518563e8e7362dee7936b90d1e7b
Tony Arcieri
2020-12-16T14:15:19
pkcs8: add `AlgorithmParameters` enum (#138) This commit replaces the previous special casing of RSA `AlgorithmInfo` with a more general and extensible solution. The `parameters` field of `AlgorithmInfo` is now modeled as an optional enum, which presently has `Null` and `Oid` variants. With this, the RFC 3279 ...
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 7977581..ebcd99f 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -3,12 +3,6 @@ use crate::{asn1, Error, ObjectIdentifier, Result}; use core::convert::TryFrom; -/// [`AlgorithmIdentifier`] OID for RSA. -/// We special case handlin...
6
62
47
f627dbc288e655c2ab94d899e6be2f652d52eaa9
Tony Arcieri
2020-12-14T22:32:04
pkcs8: special case RSA AlgorithmIdentifier parameters encoding (#135) The immediate goal of this change is to ensure Ed25519 keys are encoded with AlgorithmIdentifiers that match keys generated by OpenSSL. The `parameters` field of `AlgorithmIdentifier` is defined as being optional, and Ed25519 keys take advanta...
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index e4dea46..7977581 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -3,6 +3,12 @@ use crate::{asn1, Error, ObjectIdentifier, Result}; use core::convert::TryFrom; +/// [`AlgorithmIdentifier`] OID for RSA. +/// We special case handlin...
4
79
12
58d4e150bceeec83209f9ce1834d5e691a3df8f1
Tony Arcieri
2020-12-14T15:34:07
pkcs8: linkify RFC 5208 in rustdoc (#132)
diff --git a/pkcs8/src/lib.rs b/pkcs8/src/lib.rs index 1d08e21..e8886b0 100644 --- a/pkcs8/src/lib.rs +++ b/pkcs8/src/lib.rs @@ -1,5 +1,5 @@ //! Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: -//! Private-Key Information Syntax Specification (RFC 5208). +//! Private-Key Information Syntax Spe...
1
3
1
e71b1c0fb134c2e4feddbe530091b317fd3910d5
Tony Arcieri
2020-12-14T15:00:22
pkcs8: rustdoc improvements (#130) Expands the intro section of the rustdoc
diff --git a/pkcs8/src/lib.rs b/pkcs8/src/lib.rs index 6e3df4c..d678ea8 100644 --- a/pkcs8/src/lib.rs +++ b/pkcs8/src/lib.rs @@ -4,14 +4,26 @@ //! # About //! //! This is a minimalistic library targeting `no_std` platforms and small code -//! size. It avoids the use of any heap-based data structures. +//! size. It s...
1
15
3
ae39c99b024745be50118c2235a268220ab3fce9
Tony Arcieri
2020-12-14T14:38:37
pkcs8: error enum (#128) The previous opaque `Error` makes it impossible to distinguish from decoding errors (i.e. malformed ASN.1 DER) versus common filesystem errors which might occur, such as files not existing or permission errors. This commit adds a very simple error enum which makes it possible to disting...
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 20af93c..e4dea46 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -36,7 +36,7 @@ impl AlgorithmIdentifier { if bytes.is_empty() { Ok(algorithm) } else { - Err(Error) + Err(Error::De...
6
117
60
516b19d0b90e2608b9158e0af56380a169ba9b1d
Tony Arcieri
2020-12-14T14:12:15
pkcs8: rename `load_*_file` methods to `read_*_file` (#127) Renames methods which read data from files to be prefixed with `read_*` This is more consistent with Rust's `io::Read` trait.
diff --git a/pkcs8/src/document.rs b/pkcs8/src/document.rs index 5ab05d6..19dee32 100644 --- a/pkcs8/src/document.rs +++ b/pkcs8/src/document.rs @@ -55,7 +55,7 @@ impl PrivateKeyDocument { /// filesystem (binary format). #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] - pub fn l...
4
20
20
bae81af278471df753bb1baea8dcb4601ccfabfe
Tony Arcieri
2020-12-14T14:05:55
pkcs8: file writing methods for public/private keys (#126) Support for writing keys to files when the `std` feature is enabled. On Unix platforms, this also takes care of setting restricted file permissions so private keys aren't world/group readable.
diff --git a/pkcs8/src/document.rs b/pkcs8/src/document.rs index d0c8f36..5ab05d6 100644 --- a/pkcs8/src/document.rs +++ b/pkcs8/src/document.rs @@ -69,6 +69,21 @@ impl PrivateKeyDocument { Self::from_pem(pem) } + /// Write ASN.1 DER-encoded PKCS#8 private key to the given path + #[cfg(feature = "...
2
87
0
cce8795398436cb0877da7a11c56d3767d953b75
Tony Arcieri
2020-12-13T17:35:43
pkcs8: add methods to load document types from files (#125) Also use them to impl the trait methods to load files, and add additional tests.
diff --git a/pkcs8/src/document.rs b/pkcs8/src/document.rs index 468837d..d0c8f36 100644 --- a/pkcs8/src/document.rs +++ b/pkcs8/src/document.rs @@ -9,6 +9,9 @@ use core::{ }; use zeroize::{Zeroize, Zeroizing}; +#[cfg(feature = "std")] +use std::{fs, path::Path, str}; + #[cfg(feature = "pem")] use {crate::pem, al...
4
105
33
24bd990dd952d99bc3520e59c88f0cd2f94239f6
Tony Arcieri
2020-12-13T16:12:33
pkcs8: PEM serialization support (#124) Support for serializing the following as PEM: - `PrivateKeyInfo`, `SubjectPublicKeyInfo` - `PrivateKeyDocument`, `PublicKeyDocument` - Trait-based serialization via `ToPrivateKey`, `ToPublicKey`
diff --git a/pkcs8/src/document.rs b/pkcs8/src/document.rs index 4523b1b..468837d 100644 --- a/pkcs8/src/document.rs +++ b/pkcs8/src/document.rs @@ -3,13 +3,14 @@ use crate::{Error, PrivateKeyInfo, Result, SubjectPublicKeyInfo}; use alloc::{borrow::ToOwned, vec::Vec}; -use core::{convert::TryFrom, fmt}; -use zeroiz...
7
117
60
1e54d8b717da14a02f09693661464ddd8fb6ad6e
Tony Arcieri
2020-12-13T02:45:28
pkcs8: add `ToPrivateKey`/`ToPublicKey` traits (#123) Traits for serializing private and public keys
diff --git a/pkcs8/src/lib.rs b/pkcs8/src/lib.rs index 6ea19bd..c59c35d 100644 --- a/pkcs8/src/lib.rs +++ b/pkcs8/src/lib.rs @@ -53,7 +53,7 @@ pub use crate::{ error::{Error, Result}, private_key_info::PrivateKeyInfo, spki::SubjectPublicKeyInfo, - traits::{FromPrivateKey, FromPublicKey}, + traits::...
2
26
2
5f13c7d4da50d1eaf36645adc567c282c8e18304
Tony Arcieri
2020-12-13T02:27:58
pkcs8: PEM encoder support (#122) Support for encoding keys in RFC 7468 "PEM encoding" format.
diff --git a/pkcs8/src/document.rs b/pkcs8/src/document.rs index 85f2771..4523b1b 100644 --- a/pkcs8/src/document.rs +++ b/pkcs8/src/document.rs @@ -38,7 +38,7 @@ impl PrivateKeyDocument { #[cfg(feature = "pem")] #[cfg_attr(docsrs, doc(cfg(feature = "pem")))] pub fn from_pem(s: &str) -> Result<Self> { - ...
6
118
25
3b600f6904eddca0d2b03e372b60a6a05afef67d
Tony Arcieri
2020-12-13T00:41:53
pkcs8: SPKI encoder (#121) Support for encoding SubjectPublicKeyInfo as ASN.1 DER
diff --git a/pkcs8/src/algorithm.rs b/pkcs8/src/algorithm.rs index 7f05b1c..20af93c 100644 --- a/pkcs8/src/algorithm.rs +++ b/pkcs8/src/algorithm.rs @@ -40,7 +40,7 @@ impl AlgorithmIdentifier { } } - /// Write an ASN.1 DER-encoded [`AlgorithmIdentifier`] to the provided + /// Write ASN.1 DER-encod...
5
72
7