Skip to content

der_derive: add DecodeValue, EncodeValue macros - #1722

Merged
baloo merged 2 commits into
RustCrypto:masterfrom
dishmaker:dishmaker/sequence_encode_decode
Mar 24, 2025
Merged

der_derive: add DecodeValue, EncodeValue macros#1722
baloo merged 2 commits into
RustCrypto:masterfrom
dishmaker:dishmaker/sequence_encode_decode

Conversation

@dishmaker

@dishmakerdishmaker commented Mar 15, 2025

Copy link
Copy Markdown
Contributor

Fixes

Adds DecodeValue macro:

#[derive(DecodeValue)]structMyDecodeOnly{field:u8,}implFixedTagforMyDecodeOnly{constTAG:Tag = Tag::Sequence;}

and EncodeValue:

#[derive(EncodeValue)]structMyEncodeOnly{field:u8,}implFixedTagforMyEncodeOnly{constTAG:Tag = Tag::Sequence;}

@tarcieri

Copy link
Copy Markdown
Member

There aren't corresponding traits for these (and I don't think there should be).

Instead I would suggest making it possible to derive DecodeValue and EncodeValue

@dishmakerdishmaker changed the title der_derive: add SequenceDecode, SequenceEncode macrosder_derive: add DecodeValue, EncodeValue macrosMar 15, 2025
@baloo
baloo merged commit e0910cd into RustCrypto:masterMar 24, 2025
@baloo

Copy link
Copy Markdown
Member

Thanks a lot!

@tarcieritarcieri mentioned this pull request Feb 11, 2026
tarcieri added a commit that referenced this pull request Feb 11, 2026
## Added
- `Sequence`, `Enumerated` and `Choice` macros now support `#[asn1(error = Ty)]`
attribute that provides a custom error type for `Decode`/`DecodeValue`
implementations (#1560)
- `BitString` macro (#1720, #1733)
- `DecodeValue`, `EncodeValue` macros (#1722)
- Derive support for `APPLICATION` and `PRIVATE` tags (#1825)
- Impl `DecodeValue` for `Choice` (#1986)
## Changed
- Use `TryFrom` conversions for `asn1(type = ...)` (#1562)
- Rewrite `EncodeValue::value_len` as simple addition (#1810)
- Change OctetStringRef `&` handling due to `der` type changes
(#1998, #2040, #2043)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dishmaker@tarcieri@baloo