diff options
Diffstat (limited to 'vendor/der')
-rw-r--r-- | vendor/der/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/der/CHANGELOG.md | 36 | ||||
-rw-r--r-- | vendor/der/Cargo.toml | 6 | ||||
-rw-r--r-- | vendor/der/src/arrayvec.rs | 17 | ||||
-rw-r--r-- | vendor/der/src/asn1/generalized_time.rs | 2 | ||||
-rw-r--r-- | vendor/der/src/asn1/sequence_of.rs | 2 | ||||
-rw-r--r-- | vendor/der/src/asn1/set_of.rs | 129 | ||||
-rw-r--r-- | vendor/der/src/asn1/utc_time.rs | 3 | ||||
-rw-r--r-- | vendor/der/src/datetime.rs | 12 | ||||
-rw-r--r-- | vendor/der/src/decode.rs | 12 | ||||
-rw-r--r-- | vendor/der/src/encode.rs | 16 | ||||
-rw-r--r-- | vendor/der/src/error.rs | 4 | ||||
-rw-r--r-- | vendor/der/src/ord.rs | 16 | ||||
-rw-r--r-- | vendor/der/src/tag.rs | 4 | ||||
-rw-r--r-- | vendor/der/tests/derive.rs | 4 | ||||
-rw-r--r-- | vendor/der/tests/set_of.rs | 14 |
16 files changed, 231 insertions, 48 deletions
diff --git a/vendor/der/.cargo-checksum.json b/vendor/der/.cargo-checksum.json index cf4c97546..5f3ea3acd 100644 --- a/vendor/der/.cargo-checksum.json +++ b/vendor/der/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"7c085708805a8bb3690db60671b177ccf0fdf6d8e6939796e8653510d4816e8b","Cargo.toml":"e0e70fb3ce9cf0ba63007a146781f8f5cda1620b51ba27b2a8a6b9e5631dd5ba","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"ad64fcb9589f162720f3cc5010ad76ca6ad3764e11861f9192c489df176bb71d","README.md":"7eca00af3894b1bf13f1b50f69e8152b388b0fa1349a272e6c665f70ad3c4f31","src/arrayvec.rs":"0f338629310f583194ab03fb87b588bf3fb3dbd67a40d776916c7050462998f3","src/asn1.rs":"1e3666816b3ad85d76e7594e8f06ff0a0c099e12e51d7e34e26a7afd1736c26d","src/asn1/any.rs":"62c484808ab8167704c4d3ff635a650272b2689ccf0f100623589248a84abad5","src/asn1/bit_string.rs":"b34af7569a6eace60b9b8b1429b8d474e75e176c7682d79c002121c040b598fc","src/asn1/boolean.rs":"62f7b026f3990cc21dd4010d1bb26a5d06a6ae7c12cfc1c7d27e551781706291","src/asn1/choice.rs":"721a1322b862e060020b1af9020f7bd80958646c6508aa57aa999d774126ad13","src/asn1/context_specific.rs":"a1ec291b657581f26fee59de02877ea5d287468cf3dfc54a6803ab168bbfc91c","src/asn1/generalized_time.rs":"be93ab94ab4ef7ff36d028b5559a2e32f54fb289d33af941f809b7b20492c52d","src/asn1/ia5_string.rs":"3b8ff8c6b147041803a9a5e20f2ac65d7e8906668198fbf90e5225e8f0ea03f6","src/asn1/integer.rs":"daabe34a2b234735bc5bd5ce9350fa687b5f8e602f5367202c48bb91fc3cc808","src/asn1/integer/int.rs":"9c6d72ded7e2d819ec463853e937436c7b8e9baaeed5767e6a316dc5b1b79dde","src/asn1/integer/uint.rs":"3f96610aa6a12a23c9b4f46bf2602207bac35682c1c5fa9fedbe942ff253c285","src/asn1/internal_macros.rs":"0891dfaa499ddfb0e1ca5b857ccd91e652acb61ddbc150737c73029a37daecc2","src/asn1/null.rs":"c28cddc9515b37e1045b75580fb8e53deb7e5649c3a4f0f7f94508267b56600a","src/asn1/octet_string.rs":"ba0713042a735ac30319916bdde9dec4cf1c5b2223c369dc78d53d734bc4d92c","src/asn1/oid.rs":"0448b47bb62c4366e11aabf841bb615964d31530bf9ef67a79bdc1c3c8375d17","src/asn1/optional.rs":"782b9563ad34a405c5adb7fb9b165c2ade57091ef6692698f6ac56209809b1f6","src/asn1/printable_string.rs":"d81e4a059b9d383ce5b72365ebc6bac4878b6e6b67b6ce69a482a34ad4acd761","src/asn1/real.rs":"6513c27c6f5862b8eebe036e0dab9b61b3a91e5a8c5bc995189ddd8278610b1f","src/asn1/sequence.rs":"74e9ac1aaef547ff4288f899d216e63ac081a8415302a15472069d3bf42376ff","src/asn1/sequence_of.rs":"1181936dff1fe3006ee1371ed49fbdbc4713aac282f9d892e9bad1688eb743f8","src/asn1/set_of.rs":"88586a0b3d10a228f4536a6a4036a4340b076a5b907e9012e969db6602337db0","src/asn1/teletex_string.rs":"ffaac60318ba4bfd711c5c54972bf4065f3bccf0c4f25a07d3464d3dc47a44d9","src/asn1/utc_time.rs":"34c92f16b22583c384a89dc007c5b282452401c91c9aa2c0ece6a88a2d3c7148","src/asn1/utf8_string.rs":"c335501488efbc5ce54781e99038e84d6f848c09fe88b53490f9fb4771e5e4b9","src/asn1/videotex_string.rs":"8a663e58e8c73e860613ec7b3078269a6b0e5c371f9d937bd1d4e1bb09f4f28f","src/bytes_owned.rs":"05c1c95bdf18025aa73c6ea5bad5d01850ebf14ed080f344d265a54d5cba57fe","src/bytes_ref.rs":"6c7d2dd1de785180c1ab8235e5f59778b55bdb0e656eb7e82dafdc6b705f51ac","src/datetime.rs":"decf75340d8cca4f81b6238c3a7c0a742011dde78dc4f7c7ecd9b4e5c6831469","src/decode.rs":"8a3182fa175d3af05c95631c3d833e5f997a566f410cc42cb064dd6de6e0840d","src/document.rs":"a56d2aa413892becec182f2c8a32377551ed0fdd3ccb292c41b64c1f48b69dad","src/encode.rs":"431f5c3cb89d2a7332c255b9189f427feea4a452581f3778e297ac29ce84bbd8","src/encode_ref.rs":"8b0d0010780335efd6bedb3659caf33ed7e514c8c7ae22c701eb4bdea98b3dbd","src/error.rs":"44edfd781e149248e78b7e7e6488c01fa4179d007a8103100025d99bae56d1a0","src/header.rs":"33ddb6b8c03c81f163a0d06b1055ccd515618658b6b2ae6b1e47ab84fa96d4f4","src/length.rs":"283b0f4eb8fba660b742e7cba0cb420610ecd8e839cf467c2fea8584d60485cf","src/lib.rs":"a4aad3d71f3ff18d692088d37f0c409f68cdeee22218795c2ca2a83b029e4f54","src/ord.rs":"79f810acda711b4bc6209e949d29609ce37a934f1edc1b91ac86abcefb020d72","src/reader.rs":"e065486cb68fab6831ddee0f4a9b9635a05259cc1f0ec2939de767f6e375743f","src/reader/nested.rs":"6e5ab8c7cd54f867c8faa60545c441cbe5634f78a91be75bcbd31692fed5fcf0","src/reader/pem.rs":"b5c5e6e7c4737c4f06dc126ae246f5b3cdd1dc4165401bd5219552fcd5e49e7f","src/reader/slice.rs":"6da8050380694ba43effdfaa160e098dd152748af897bef41c6020f9853a76ef","src/referenced.rs":"07f20e75e4b003469d687d4412dd3d5411c92cbbacb7d3c74b646d1aebbd65ff","src/str_owned.rs":"be5389656b3978a0b5b32ca5072feb902b5c49f831045fa214f2e84a8c202000","src/str_ref.rs":"4e4f928ec851ab50ad825792ae42549776d12609ed09da8b7bf2531eec6bd773","src/tag.rs":"bfdd4a58f9f3a8c38e1550d529b828c96741800a90840e5e280fb02e88547d6d","src/tag/class.rs":"dcb78907dbaaf588db0e0929eacd5394553c6ea7f69e8948d733c2597f35d016","src/tag/mode.rs":"52854315fcedf0476015e4afd55c8699f4d4b69d497f58737b0f2572bcaa89bf","src/tag/number.rs":"e89da7d085cdd446bb021c5a5abd46aa53fb95b572f2e15e84cc87b4e2bda86a","src/writer.rs":"36ef12ce394c857b2fc28435dfdac8f11c9b572065e4226781f2af0496d9df60","src/writer/pem.rs":"2d87fbb460fe6f0ff8cf38df2660b09abb0d640def86037b10b2211197ef7e65","src/writer/slice.rs":"7e8c63cb58748cd1f3cd4c65162ce14ef9e9ee07ffc992b6aaef6ff0862495d2","tests/datetime.proptest-regressions":"f88a3c34c88b8438da12a92d47520e1bc926ed80ce890fd4eff4fdded80d3541","tests/datetime.rs":"e8fd8156618e5f8c0378b41617376e589405966cf284887cb3f73617f854a07f","tests/derive.rs":"f469fe40b816104fca4f5758c0a7a837f915a19b919aa1a0f63e0f635db9bdc7","tests/examples/spki.der":"55dd4c74b0e48534e2f4e173ceceb50df8f27a7ac2aa8991cc7ae914e030bced","tests/examples/spki.pem":"36d717203cbca1812f05f30e0415251c928b659882092e653221a028571c6853","tests/pem.rs":"e1c27fae3d6cf0d357f49e12fb826bda977134076a5fdd60d38715d1bbc9d9fa","tests/set_of.rs":"5712f86533eac987031ad4f02bc999c2c7c2ba06becfb8224d1a4b2b65c725d4"},"package":"82b10af9f9f9f2134a42d3f8aa74658660f2e0234b0eb81bd171df8aa32779ed"}
\ No newline at end of file +{"files":{"CHANGELOG.md":"278fb96f82b835b553647cfd14641e7aca7f10f46d0eab5323d2f9918f717e47","Cargo.toml":"e8c4a40eb85ef93d1776c960625d6da2bd7c8282d4417cdedd07b21108ef963a","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"ad64fcb9589f162720f3cc5010ad76ca6ad3764e11861f9192c489df176bb71d","README.md":"7eca00af3894b1bf13f1b50f69e8152b388b0fa1349a272e6c665f70ad3c4f31","src/arrayvec.rs":"725cb437e439ab9ab9b9a11faa3993d85308692affd96a854fedb17723c2993f","src/asn1.rs":"1e3666816b3ad85d76e7594e8f06ff0a0c099e12e51d7e34e26a7afd1736c26d","src/asn1/any.rs":"62c484808ab8167704c4d3ff635a650272b2689ccf0f100623589248a84abad5","src/asn1/bit_string.rs":"b34af7569a6eace60b9b8b1429b8d474e75e176c7682d79c002121c040b598fc","src/asn1/boolean.rs":"62f7b026f3990cc21dd4010d1bb26a5d06a6ae7c12cfc1c7d27e551781706291","src/asn1/choice.rs":"721a1322b862e060020b1af9020f7bd80958646c6508aa57aa999d774126ad13","src/asn1/context_specific.rs":"a1ec291b657581f26fee59de02877ea5d287468cf3dfc54a6803ab168bbfc91c","src/asn1/generalized_time.rs":"2d337c6927c56975138425b63a764b03df62e43dc2c76b44d9e51fb8c76fb29b","src/asn1/ia5_string.rs":"3b8ff8c6b147041803a9a5e20f2ac65d7e8906668198fbf90e5225e8f0ea03f6","src/asn1/integer.rs":"daabe34a2b234735bc5bd5ce9350fa687b5f8e602f5367202c48bb91fc3cc808","src/asn1/integer/int.rs":"9c6d72ded7e2d819ec463853e937436c7b8e9baaeed5767e6a316dc5b1b79dde","src/asn1/integer/uint.rs":"3f96610aa6a12a23c9b4f46bf2602207bac35682c1c5fa9fedbe942ff253c285","src/asn1/internal_macros.rs":"0891dfaa499ddfb0e1ca5b857ccd91e652acb61ddbc150737c73029a37daecc2","src/asn1/null.rs":"c28cddc9515b37e1045b75580fb8e53deb7e5649c3a4f0f7f94508267b56600a","src/asn1/octet_string.rs":"ba0713042a735ac30319916bdde9dec4cf1c5b2223c369dc78d53d734bc4d92c","src/asn1/oid.rs":"0448b47bb62c4366e11aabf841bb615964d31530bf9ef67a79bdc1c3c8375d17","src/asn1/optional.rs":"782b9563ad34a405c5adb7fb9b165c2ade57091ef6692698f6ac56209809b1f6","src/asn1/printable_string.rs":"d81e4a059b9d383ce5b72365ebc6bac4878b6e6b67b6ce69a482a34ad4acd761","src/asn1/real.rs":"6513c27c6f5862b8eebe036e0dab9b61b3a91e5a8c5bc995189ddd8278610b1f","src/asn1/sequence.rs":"74e9ac1aaef547ff4288f899d216e63ac081a8415302a15472069d3bf42376ff","src/asn1/sequence_of.rs":"bd6ee2398ca5ffa7ee31633b3a79543d73f742a15cf7a1591c9493981430766d","src/asn1/set_of.rs":"208667d136f66c123a92a3f04475c068c1613e6ee0bd115e9f2766a45a0c4223","src/asn1/teletex_string.rs":"ffaac60318ba4bfd711c5c54972bf4065f3bccf0c4f25a07d3464d3dc47a44d9","src/asn1/utc_time.rs":"37c25624a7a5d86a432619702a54959bffceec411fd5312c9ec14f1aa9af12a2","src/asn1/utf8_string.rs":"c335501488efbc5ce54781e99038e84d6f848c09fe88b53490f9fb4771e5e4b9","src/asn1/videotex_string.rs":"8a663e58e8c73e860613ec7b3078269a6b0e5c371f9d937bd1d4e1bb09f4f28f","src/bytes_owned.rs":"05c1c95bdf18025aa73c6ea5bad5d01850ebf14ed080f344d265a54d5cba57fe","src/bytes_ref.rs":"6c7d2dd1de785180c1ab8235e5f59778b55bdb0e656eb7e82dafdc6b705f51ac","src/datetime.rs":"d0f269d07f4d5ba9a5f7b9b0ae4727b348487cda73210bb8fc5d4575d5a19f1b","src/decode.rs":"bc4b4e5afd1cfa4878d75283b294b52062f800d568389790200db8c239feddae","src/document.rs":"a56d2aa413892becec182f2c8a32377551ed0fdd3ccb292c41b64c1f48b69dad","src/encode.rs":"6a29ff6e583eb2bd8b6a77e06d61378c75c451bb8ca670df480a6ac0dfb8192d","src/encode_ref.rs":"8b0d0010780335efd6bedb3659caf33ed7e514c8c7ae22c701eb4bdea98b3dbd","src/error.rs":"d33bba19755d5e36dbcf864332c1c00b0f29484a0e5929355874edf8f4699bbe","src/header.rs":"33ddb6b8c03c81f163a0d06b1055ccd515618658b6b2ae6b1e47ab84fa96d4f4","src/length.rs":"283b0f4eb8fba660b742e7cba0cb420610ecd8e839cf467c2fea8584d60485cf","src/lib.rs":"a4aad3d71f3ff18d692088d37f0c409f68cdeee22218795c2ca2a83b029e4f54","src/ord.rs":"6b9685d805a5e0060e2432234e04e93ce81e27fdc7711eae86ba2d01c00b70f7","src/reader.rs":"e065486cb68fab6831ddee0f4a9b9635a05259cc1f0ec2939de767f6e375743f","src/reader/nested.rs":"6e5ab8c7cd54f867c8faa60545c441cbe5634f78a91be75bcbd31692fed5fcf0","src/reader/pem.rs":"b5c5e6e7c4737c4f06dc126ae246f5b3cdd1dc4165401bd5219552fcd5e49e7f","src/reader/slice.rs":"6da8050380694ba43effdfaa160e098dd152748af897bef41c6020f9853a76ef","src/referenced.rs":"07f20e75e4b003469d687d4412dd3d5411c92cbbacb7d3c74b646d1aebbd65ff","src/str_owned.rs":"be5389656b3978a0b5b32ca5072feb902b5c49f831045fa214f2e84a8c202000","src/str_ref.rs":"4e4f928ec851ab50ad825792ae42549776d12609ed09da8b7bf2531eec6bd773","src/tag.rs":"1b2c19072ff96fafa74e4200910e31e29808139068409e115b7d31c6b99f0e01","src/tag/class.rs":"dcb78907dbaaf588db0e0929eacd5394553c6ea7f69e8948d733c2597f35d016","src/tag/mode.rs":"52854315fcedf0476015e4afd55c8699f4d4b69d497f58737b0f2572bcaa89bf","src/tag/number.rs":"e89da7d085cdd446bb021c5a5abd46aa53fb95b572f2e15e84cc87b4e2bda86a","src/writer.rs":"36ef12ce394c857b2fc28435dfdac8f11c9b572065e4226781f2af0496d9df60","src/writer/pem.rs":"2d87fbb460fe6f0ff8cf38df2660b09abb0d640def86037b10b2211197ef7e65","src/writer/slice.rs":"7e8c63cb58748cd1f3cd4c65162ce14ef9e9ee07ffc992b6aaef6ff0862495d2","tests/datetime.proptest-regressions":"f88a3c34c88b8438da12a92d47520e1bc926ed80ce890fd4eff4fdded80d3541","tests/datetime.rs":"e8fd8156618e5f8c0378b41617376e589405966cf284887cb3f73617f854a07f","tests/derive.rs":"5102bfac06f50f258d0e4c11597f9a60a78937461ebdb6a0cd43a8e749678db8","tests/examples/spki.der":"55dd4c74b0e48534e2f4e173ceceb50df8f27a7ac2aa8991cc7ae914e030bced","tests/examples/spki.pem":"36d717203cbca1812f05f30e0415251c928b659882092e653221a028571c6853","tests/pem.rs":"e1c27fae3d6cf0d357f49e12fb826bda977134076a5fdd60d38715d1bbc9d9fa","tests/set_of.rs":"c0562109025829e794e00f2097eaa8f7ed3d2b2aa1baca08fbc0c552f6980ab1"},"package":"56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17"}
\ No newline at end of file diff --git a/vendor/der/CHANGELOG.md b/vendor/der/CHANGELOG.md index fd578f0a7..a5063a6c5 100644 --- a/vendor/der/CHANGELOG.md +++ b/vendor/der/CHANGELOG.md @@ -4,6 +4,42 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.7.6 (2023-05-16) +### Added +- `SetOfVec::{extend, from_iter}` methods ([#1065]) +- `SetOf(Vec)::{insert, insert_ordered}` methods ([#1067]) + +### Changed +- Deprecate `SetOf(Vec)::add` ([#1067]) + +### Fixed +- Off-by-one error in `BMPString` tag ([#1037]) +- Handling of non-unique items in `SetOf`(Vec) ([#1066]) + +[#1037]: https://github.com/RustCrypto/formats/pull/1037 +[#1065]: https://github.com/RustCrypto/formats/pull/1065 +[#1066]: https://github.com/RustCrypto/formats/pull/1066 +[#1067]: https://github.com/RustCrypto/formats/pull/1067 + +## 0.7.5 (2023-04-24) +### Added +- adds support for `DateTime::INFINITY` ([#1026]) + +[#1026]: https://github.com/RustCrypto/formats/pull/1026 + +## 0.7.4 (2023-04-19) +### Added +- `Decode` and `Encode` impls for `PhantomData` ([#1009]) +- `ValueOrd` and `DerOrd` impls for `PhantomData` ([#1012]) + +### Changed +- Bump `hex-literal` dependency to v0.4.1 ([#999]) +- Bump `der_derive` dependency to v0.7.1 ([#1016]) + +[#1009]: https://github.com/RustCrypto/formats/pull/1009 +[#1012]: https://github.com/RustCrypto/formats/pull/1012 +[#1016]: https://github.com/RustCrypto/formats/pull/1016 + ## 0.7.3 (2023-04-06) ### Added - `UtcTime::MAX_YEAR` associated constant ([#989]) diff --git a/vendor/der/Cargo.toml b/vendor/der/Cargo.toml index 9e4d73ce2..40e2e6035 100644 --- a/vendor/der/Cargo.toml +++ b/vendor/der/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.65" name = "der" -version = "0.7.3" +version = "0.7.6" authors = ["RustCrypto Developers"] description = """ Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules @@ -54,7 +54,7 @@ version = "0.9.2" optional = true [dependencies.der_derive] -version = "0.7" +version = "0.7.1" optional = true [dependencies.flagset] @@ -77,7 +77,7 @@ optional = true default-features = false [dev-dependencies.hex-literal] -version = "0.3.3" +version = "0.4.1" [dev-dependencies.proptest] version = "1" diff --git a/vendor/der/src/arrayvec.rs b/vendor/der/src/arrayvec.rs index 21f134196..6ce608d97 100644 --- a/vendor/der/src/arrayvec.rs +++ b/vendor/der/src/arrayvec.rs @@ -23,14 +23,11 @@ impl<T, const N: usize> ArrayVec<T, N> { } } - /// Add an element to this [`ArrayVec`]. - /// - /// Items MUST be added in lexicographical order according to the `Ord` - /// impl on `T`. - pub fn add(&mut self, element: T) -> Result<()> { + /// Push an item into this [`ArrayVec`]. + pub fn push(&mut self, item: T) -> Result<()> { match self.length.checked_add(1) { Some(n) if n <= N => { - self.elements[self.length] = Some(element); + self.elements[self.length] = Some(item); self.length = n; Ok(()) } @@ -138,11 +135,11 @@ mod tests { #[test] fn add() { let mut vec = ArrayVec::<u8, 3>::new(); - vec.add(1).unwrap(); - vec.add(2).unwrap(); - vec.add(3).unwrap(); + vec.push(1).unwrap(); + vec.push(2).unwrap(); + vec.push(3).unwrap(); - assert_eq!(vec.add(4).err().unwrap(), ErrorKind::Overlength.into()); + assert_eq!(vec.push(4).err().unwrap(), ErrorKind::Overlength.into()); assert_eq!(vec.len(), 3); } } diff --git a/vendor/der/src/asn1/generalized_time.rs b/vendor/der/src/asn1/generalized_time.rs index f7b6f180f..8837917c3 100644 --- a/vendor/der/src/asn1/generalized_time.rs +++ b/vendor/der/src/asn1/generalized_time.rs @@ -37,7 +37,7 @@ impl GeneralizedTime { const LENGTH: usize = 15; /// Create a [`GeneralizedTime`] from a [`DateTime`]. - pub fn from_date_time(datetime: DateTime) -> Self { + pub const fn from_date_time(datetime: DateTime) -> Self { Self(datetime) } diff --git a/vendor/der/src/asn1/sequence_of.rs b/vendor/der/src/asn1/sequence_of.rs index 42c2a9ca8..befb0298f 100644 --- a/vendor/der/src/asn1/sequence_of.rs +++ b/vendor/der/src/asn1/sequence_of.rs @@ -30,7 +30,7 @@ impl<T, const N: usize> SequenceOf<T, N> { /// Add an element to this [`SequenceOf`]. pub fn add(&mut self, element: T) -> Result<()> { - self.inner.add(element) + self.inner.push(element) } /// Get an element of this [`SequenceOf`]. diff --git a/vendor/der/src/asn1/set_of.rs b/vendor/der/src/asn1/set_of.rs index e8f20e9c3..ff0131242 100644 --- a/vendor/der/src/asn1/set_of.rs +++ b/vendor/der/src/asn1/set_of.rs @@ -44,19 +44,32 @@ where } } - /// Add an element to this [`SetOf`]. + /// Add an item to this [`SetOf`]. /// /// Items MUST be added in lexicographical order according to the /// [`DerOrd`] impl on `T`. + #[deprecated(since = "0.7.6", note = "use `insert` or `insert_ordered` instead")] pub fn add(&mut self, new_elem: T) -> Result<()> { + self.insert_ordered(new_elem) + } + + /// Insert an item into this [`SetOf`]. + pub fn insert(&mut self, item: T) -> Result<()> { + self.inner.push(item)?; + der_sort(self.inner.as_mut()) + } + + /// Insert an item into this [`SetOf`]. + /// + /// Items MUST be added in lexicographical order according to the + /// [`DerOrd`] impl on `T`. + pub fn insert_ordered(&mut self, item: T) -> Result<()> { // Ensure set elements are lexicographically ordered - if let Some(last_elem) = self.inner.last() { - if new_elem.der_cmp(last_elem)? != Ordering::Greater { - return Err(ErrorKind::SetOrdering.into()); - } + if let Some(last) = self.inner.last() { + check_der_ordering(last, &item)?; } - self.inner.add(new_elem) + self.inner.push(item) } /// Get the nth element from this [`SetOf`]. @@ -100,7 +113,7 @@ where let mut result = Self::new(); while !reader.is_finished() { - result.inner.add(T::decode(reader)?)?; + result.inner.push(T::decode(reader)?)?; } der_sort(result.inner.as_mut())?; @@ -147,7 +160,7 @@ where let mut result = SetOf::new(); for elem in arr { - result.add(elem)?; + result.insert_ordered(elem)?; } Ok(result) @@ -214,19 +227,56 @@ where } } + /// Create a new [`SetOfVec`] from the given iterator. + /// + /// Note: this is an inherent method instead of an impl of the + /// [`FromIterator`] trait in order to be fallible. + #[allow(clippy::should_implement_trait)] + pub fn from_iter<I>(iter: I) -> Result<Self> + where + I: IntoIterator<Item = T>, + { + Vec::from_iter(iter).try_into() + } + /// Add an element to this [`SetOfVec`]. /// /// Items MUST be added in lexicographical order according to the /// [`DerOrd`] impl on `T`. - pub fn add(&mut self, new_elem: T) -> Result<()> { + #[deprecated(since = "0.7.6", note = "use `insert` or `insert_ordered` instead")] + pub fn add(&mut self, item: T) -> Result<()> { + self.insert_ordered(item) + } + + /// Extend a [`SetOfVec`] using an iterator. + /// + /// Note: this is an inherent method instead of an impl of the + /// [`Extend`] trait in order to be fallible. + pub fn extend<I>(&mut self, iter: I) -> Result<()> + where + I: IntoIterator<Item = T>, + { + self.inner.extend(iter); + der_sort(&mut self.inner) + } + + /// Insert an item into this [`SetOfVec`]. Must be unique. + pub fn insert(&mut self, item: T) -> Result<()> { + self.inner.push(item); + der_sort(&mut self.inner) + } + + /// Insert an item into this [`SetOfVec`]. Must be unique. + /// + /// Items MUST be added in lexicographical order according to the + /// [`DerOrd`] impl on `T`. + pub fn insert_ordered(&mut self, item: T) -> Result<()> { // Ensure set elements are lexicographically ordered - if let Some(last_elem) = self.inner.last() { - if new_elem.der_cmp(last_elem)? != Ordering::Greater { - return Err(ErrorKind::SetOrdering.into()); - } + if let Some(last) = self.inner.last() { + check_der_ordering(last, &item)?; } - self.inner.push(new_elem); + self.inner.push(item); Ok(()) } @@ -336,7 +386,6 @@ where type Error = Error; fn try_from(mut vec: Vec<T>) -> Result<SetOfVec<T>> { - // TODO(tarcieri): use `[T]::sort_by` here? der_sort(vec.as_mut_slice())?; Ok(SetOfVec { inner: vec }) } @@ -384,6 +433,15 @@ where } } +/// Ensure set elements are lexicographically ordered using [`DerOrd`]. +fn check_der_ordering<T: DerOrd>(a: &T, b: &T) -> Result<()> { + match a.der_cmp(b)? { + Ordering::Less => Ok(()), + Ordering::Equal => Err(ErrorKind::SetDuplicate.into()), + Ordering::Greater => Err(ErrorKind::SetOrdering.into()), + } +} + /// Sort a mut slice according to its [`DerOrd`], returning any errors which /// might occur during the comparison. /// @@ -398,9 +456,15 @@ fn der_sort<T: DerOrd>(slice: &mut [T]) -> Result<()> { for i in 0..slice.len() { let mut j = i; - while j > 0 && slice[j - 1].der_cmp(&slice[j])? == Ordering::Greater { - slice.swap(j - 1, j); - j -= 1; + while j > 0 { + match slice[j - 1].der_cmp(&slice[j])? { + Ordering::Less => break, + Ordering::Equal => return Err(ErrorKind::SetDuplicate.into()), + Ordering::Greater => { + slice.swap(j - 1, j); + j -= 1; + } + } } } @@ -428,22 +492,29 @@ fn validate<T: DerOrd>(slice: &[T]) -> Result<()> { Ok(()) } -#[cfg(all(test, feature = "alloc"))] +#[cfg(test)] mod tests { - use super::{SetOf, SetOfVec}; - use alloc::vec::Vec; + use super::SetOf; + #[cfg(feature = "alloc")] + use super::SetOfVec; + use crate::ErrorKind; #[test] fn setof_tryfrom_array() { let arr = [3u16, 2, 1, 65535, 0]; let set = SetOf::try_from(arr).unwrap(); - assert_eq!( - set.iter().cloned().collect::<Vec<u16>>(), - &[0, 1, 2, 3, 65535] - ); + assert!(set.iter().copied().eq([0, 1, 2, 3, 65535])); } #[test] + fn setof_tryfrom_array_reject_duplicates() { + let arr = [1u16, 1]; + let err = SetOf::try_from(arr).err().unwrap(); + assert_eq!(err.kind(), ErrorKind::SetDuplicate); + } + + #[cfg(feature = "alloc")] + #[test] fn setofvec_tryfrom_array() { let arr = [3u16, 2, 1, 65535, 0]; let set = SetOfVec::try_from(arr).unwrap(); @@ -457,4 +528,12 @@ mod tests { let set = SetOfVec::try_from(vec).unwrap(); assert_eq!(set.as_ref(), &[0, 1, 2, 3, 65535]); } + + #[cfg(feature = "alloc")] + #[test] + fn setofvec_tryfrom_vec_reject_duplicates() { + let vec = vec![1u16, 1]; + let err = SetOfVec::try_from(vec).err().unwrap(); + assert_eq!(err.kind(), ErrorKind::SetDuplicate); + } } diff --git a/vendor/der/src/asn1/utc_time.rs b/vendor/der/src/asn1/utc_time.rs index 0c10e3aff..9f2f1713b 100644 --- a/vendor/der/src/asn1/utc_time.rs +++ b/vendor/der/src/asn1/utc_time.rs @@ -25,6 +25,9 @@ use std::time::SystemTime; /// > interpreted as `19YY`; and /// > - Where `YY` is less than 50, the year SHALL be interpreted as `20YY`. /// +/// Note: Due to common operations working on `UNIX_EPOCH` [`UtcTime`]s are +/// only supported for the years 1970-2049. +/// /// [1]: https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] pub struct UtcTime(DateTime); diff --git a/vendor/der/src/datetime.rs b/vendor/der/src/datetime.rs index de28d53bb..fd09b6855 100644 --- a/vendor/der/src/datetime.rs +++ b/vendor/der/src/datetime.rs @@ -56,6 +56,18 @@ pub struct DateTime { } impl DateTime { + /// This is the maximum date represented by the [`DateTime`] + /// This corresponds to: 9999-12-31T23:59:59Z + pub const INFINITY: DateTime = DateTime { + year: 9999, + month: 12, + day: 31, + hour: 23, + minutes: 59, + seconds: 59, + unix_duration: MAX_UNIX_DURATION, + }; + /// Create a new [`DateTime`] from the given UTC time components. // TODO(tarcieri): checked arithmetic #[allow(clippy::integer_arithmetic)] diff --git a/vendor/der/src/decode.rs b/vendor/der/src/decode.rs index 0efcae69f..fe53341b3 100644 --- a/vendor/der/src/decode.rs +++ b/vendor/der/src/decode.rs @@ -1,6 +1,7 @@ //! Trait definition for [`Decode`]. use crate::{FixedTag, Header, Reader, Result, SliceReader}; +use core::marker::PhantomData; #[cfg(feature = "pem")] use crate::{pem::PemLabel, PemReader}; @@ -38,6 +39,17 @@ where } } +/// Dummy implementation for [`PhantomData`] which allows deriving +/// implementations on structs with phantom fields. +impl<'a, T> Decode<'a> for PhantomData<T> +where + T: ?Sized, +{ + fn decode<R: Reader<'a>>(_reader: &mut R) -> Result<PhantomData<T>> { + Ok(PhantomData) + } +} + /// Marker trait for data structures that can be decoded from DER without /// borrowing any data from the decoder. /// diff --git a/vendor/der/src/encode.rs b/vendor/der/src/encode.rs index d480b7bbd..28d7cba77 100644 --- a/vendor/der/src/encode.rs +++ b/vendor/der/src/encode.rs @@ -1,6 +1,7 @@ //! Trait definition for [`Encode`]. use crate::{Header, Length, Result, SliceWriter, Tagged, Writer}; +use core::marker::PhantomData; #[cfg(feature = "alloc")] use {alloc::boxed::Box, alloc::vec::Vec, core::iter}; @@ -82,6 +83,21 @@ where } } +/// Dummy implementation for [`PhantomData`] which allows deriving +/// implementations on structs with phantom fields. +impl<T> Encode for PhantomData<T> +where + T: ?Sized, +{ + fn encoded_len(&self) -> Result<Length> { + Ok(Length::ZERO) + } + + fn encode(&self, _writer: &mut impl Writer) -> Result<()> { + Ok(()) + } +} + /// PEM encoding trait. /// /// This trait is automatically impl'd for any type which impls both diff --git a/vendor/der/src/error.rs b/vendor/der/src/error.rs index 94378ef71..902863d49 100644 --- a/vendor/der/src/error.rs +++ b/vendor/der/src/error.rs @@ -227,6 +227,9 @@ pub enum ErrorKind { oid: ObjectIdentifier, }, + /// `SET` cannot contain duplicates. + SetDuplicate, + /// `SET` ordering error: items not in canonical order. SetOrdering, @@ -329,6 +332,7 @@ impl fmt::Display for ErrorKind { ErrorKind::OidUnknown { oid } => { write!(f, "unknown/unsupported OID: {}", oid) } + ErrorKind::SetDuplicate => write!(f, "SET OF contains duplicate"), ErrorKind::SetOrdering => write!(f, "SET OF ordering error"), ErrorKind::Overflow => write!(f, "integer overflow"), ErrorKind::Overlength => write!(f, "ASN.1 DER message is too long"), diff --git a/vendor/der/src/ord.rs b/vendor/der/src/ord.rs index fd967bf88..42d462340 100644 --- a/vendor/der/src/ord.rs +++ b/vendor/der/src/ord.rs @@ -1,7 +1,7 @@ //! Ordering trait. use crate::{EncodeValue, Result, Tagged}; -use core::cmp::Ordering; +use core::{cmp::Ordering, marker::PhantomData}; /// DER ordering trait. /// @@ -69,3 +69,17 @@ where Ok(length_ord) } + +/// Provide a no-op implementation for PhantomData +impl<T> ValueOrd for PhantomData<T> { + fn value_cmp(&self, _other: &Self) -> Result<Ordering> { + Ok(Ordering::Equal) + } +} + +/// Provide a no-op implementation for PhantomData +impl<T> DerOrd for PhantomData<T> { + fn der_cmp(&self, _other: &Self) -> Result<Ordering> { + Ok(Ordering::Equal) + } +} diff --git a/vendor/der/src/tag.rs b/vendor/der/src/tag.rs index b0853a846..7a1fed1b7 100644 --- a/vendor/der/src/tag.rs +++ b/vendor/der/src/tag.rs @@ -213,7 +213,7 @@ impl Tag { Tag::UtcTime => 0x17, Tag::GeneralizedTime => 0x18, Tag::VisibleString => 0x1A, - Tag::BmpString => 0x1D, + Tag::BmpString => 0x1E, Tag::Application { constructed, number, @@ -282,7 +282,7 @@ impl TryFrom<u8> for Tag { 0x17 => Ok(Tag::UtcTime), 0x18 => Ok(Tag::GeneralizedTime), 0x1A => Ok(Tag::VisibleString), - 0x1d => Ok(Tag::BmpString), + 0x1E => Ok(Tag::BmpString), 0x30 => Ok(Tag::Sequence), // constructed 0x31 => Ok(Tag::Set), // constructed 0x40..=0x7E => Ok(Tag::Application { diff --git a/vendor/der/tests/derive.rs b/vendor/der/tests/derive.rs index cb6fe183d..a8c77febc 100644 --- a/vendor/der/tests/derive.rs +++ b/vendor/der/tests/derive.rs @@ -200,6 +200,7 @@ mod enumerated { /// Custom derive test cases for the `Sequence` macro. #[cfg(feature = "oid")] mod sequence { + use core::marker::PhantomData; use der::{ asn1::{AnyRef, ObjectIdentifier, SetOf}, Decode, Encode, Sequence, ValueOrd, @@ -266,6 +267,9 @@ mod sequence { tag_mode = "IMPLICIT" )] pub only_contains_attribute_certs: bool, + + /// Test handling of PhantomData. + pub phantom: PhantomData<()>, } // Extension as defined in [RFC 5280 Section 4.1.2.9]. diff --git a/vendor/der/tests/set_of.rs b/vendor/der/tests/set_of.rs index ba43d80a2..d58399198 100644 --- a/vendor/der/tests/set_of.rs +++ b/vendor/der/tests/set_of.rs @@ -4,15 +4,21 @@ use der::{asn1::SetOfVec, DerOrd}; use proptest::{prelude::*, string::*}; +use std::collections::BTreeSet; proptest! { #[test] fn sort_equiv(bytes in bytes_regex(".{0,64}").unwrap()) { - let mut expected = bytes.clone(); - expected.sort_by(|a, b| a.der_cmp(b).unwrap()); + let mut uniq = BTreeSet::new(); - let set = SetOfVec::try_from(bytes).unwrap(); - prop_assert_eq!(expected.as_slice(), set.as_slice()); + // Ensure there are no duplicates + if bytes.iter().copied().all(move |x| uniq.insert(x)) { + let mut expected = bytes.clone(); + expected.sort_by(|a, b| a.der_cmp(b).unwrap()); + + let set = SetOfVec::try_from(bytes).unwrap(); + prop_assert_eq!(expected.as_slice(), set.as_slice()); + } } } |