RustCrypto / RustCrypto/formats

der: add `ClarifyWriter`

Open
#1,835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
338
Forks
188
Avg merge
4d 6h
Merged PRs (30d)
15

Description

I have a pretty well-written #[cfg(feature = "clarify")] - gated writer that pretty-prints DER.

Proposal: To add Encode::to_hex_clarify, that annotates tags and types.

Example of PKCS#15 ^1:

30 3E <!-- tag: SEQUENCE len: 62 type: AuthenticationObjectChoice -->
	<!-- CHOICE: Pwd -->
	<!-- field: common_object_attributes -->
	30 1B <!-- tag: SEQUENCE len: 27 type: CommonObjectAttributes -->
		<!-- field: label -->
		0C 12 <!-- tag: UTF8String len: 18 type: String -->
			41 75 74 68 65 6E 74 69 63 61 74 69 6F 6E 20 50 
			49 4E <!--  "Authentication PIN" -->
		<!-- end: String -->
		<!-- field: flags -->
		03 02 <!-- tag: BIT STRING type: CommonObjectFlags -->
			06 
			C0 
		<!-- field: auth_id -->
		04 01 <!-- tag: OCTET STRING type: OctetString -->
			05 
		<!-- field: user_consent -->
		<!-- field: access_control_rules -->
		<!-- field: current_lcs -->
	<!-- end: CommonObjectAttributes -->
	<!-- field: class_attributes -->
	30 03 <!-- tag: SEQUENCE type: CommonAuthenticationObjectAttributes -->
		<!-- field: auth_id -->
		04 01 <!-- tag: OCTET STRING type: OctetString -->
			01 
		<!-- field: auth_reference -->
		<!-- field: se_identifier -->
	<!-- field: subclass_attributes -->
	<!-- field: type_attributes -->
	A1 1A <!-- tag: CONTEXT-SPECIFIC [1] (constructed) len: 26 
                          type: ContextSpecificExplicit<PasswordAttributes> -->
		30 18 <!-- tag: SEQUENCE len: 24 type: PasswordAttributes -->
			<!-- field: pwd_flags -->
			03 03 <!-- tag: BIT STRING type: PasswordFlags -->
				04 
				48 10 
			<!-- field: pwd_type -->
			0A 01 <!-- tag: ENUMERATED type: PasswordType -->
				01 
			<!-- field: min_length -->
			02 01 <!-- tag: INTEGER type: IntegerInRange -->
				04 
			<!-- field: stored_length -->
			02 01 <!-- tag: INTEGER type: IntegerInRange -->
				04 
			<!-- field: max_length -->
			02 01 <!-- tag: INTEGER type: IntegerInRange -->
				04 
			<!-- field: pwd_reference -->
			80 01 <!-- tag: CONTEXT-SPECIFIC [0] (primitive) type: Reference -->
				01 
			<!-- field: pad_char -->
			<!-- field: last_password_change -->
			<!-- field: path -->
			30 02 <!-- tag: SEQUENCE type: Path -->
				<!-- field: efid_or_tag_choice -->
				04 00 <!-- tag: OCTET STRING type: EfidOrTagChoice -->
					<!-- CHOICE: EfidOrPath -->
					
				<!-- field: index -->
				<!-- field: length -->
			<!-- field: verif_data_history_length -->
			<!-- field: cio_security_id -->
		<!-- end: ContextSpecificExplicit<PasswordAttributes> -->
	<!-- end: PasswordAttributes -->
<!-- end: AuthenticationObjectChoice -->

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing ClarifyWriter behind the clarify feature and the Encode entry points. Compare its current pretty-printing behavior with the proposed to_hex_clarify output and the PKCS#15 example in the issue. Done means the encoded output annotates DER tags and types as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.