Skip to content

Feature/x509 general name#38

Open
JesusMcCloud wants to merge 9 commits into
developmentfrom
feature/x509GeneralName
Open

Feature/x509 general name#38
JesusMcCloud wants to merge 9 commits into
developmentfrom
feature/x509GeneralName

Conversation

@JesusMcCloud

Copy link
Copy Markdown
Contributor
  • Features:
    • Add a closed, serializable X509GeneralName hierarchy covering every RFC 5280 GeneralName alternative.
    • Make X.509 otherName extensible through OID-based open polymorphism. Unknown OIDs use a structural fallback by default, while applications can register semantic subtypes on a custom Der instance or through the startup-only DefaultDer registry.
    • Add Asn1OpenPolymorphicWithDefaultSerializer, allowing extensible models to provide a structural serializer that is automatically replaced by contextual open-polymorphism registrations when available.
    • Allow OID-based open-polymorphism configurations containing only a catchAll registration.
  • Fixes:
    • Preserve an enclosing property or inline-wrapper tag when dispatching to an open-polymorphic subtype, without conflating it with tags belonging to the selected subtype's own fields.
  • Other Changes:
    • Document provided-fallback open-polymorphism fallbacks and extending X.509 OtherName, including default-DER startup registration with test-backed source snippets.
    • Remove Deprecations

Comment on lines +6 to +9
/**
* RFC 5280 `Name`. The currently defined CHOICE has exactly one alternative, an `RDNSequence`.
*/
typealias X500Name = List<X500RelativeDistinguishedName>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vaguely prefer value class, though understand that that might cause more boilerplate than it's worth. I dislike this idea of pretending that a generic container is a "class" and then defining extensions on it, because they will then show up on any generic container that happens to match this "class", even though it's semantically not the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had it as a value class, but reverted. Going back to that is fine for me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ObjectIdentifier.decodeFromAsn1ContentBytes(it.children.first().asPrimitive().content)
Asn1.Sequence { it.children.forEach { child -> +child } }
}
/**Will be parsed leniently*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this actually mean? the comment doesn't tell me a lot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elaborated on all such kdoc comments

Comment on lines +89 to +91
/**
* Convenience constructor
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to be public (when the primary constructor is private?) on that note, why is the primary constructor private, are we objecting to construction from list of asn1element?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mishap. primary ctor should be public

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went through all and adapted

value class Directory private constructor(
val taggedValue: ExplicitlyTagged<X500Name>,
) : X509GeneralName {
val value: X500Name get() = taggedValue.value //Value classes cannot have delegated props

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the comment telling me? why it's not lazy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previsely because of that, it is not lazy. lazy is a delegate, and value classes cannot have that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it needs justification (honestly, i think the getter is far cleaner here anyway), but if you want to keep the comment (i'd remove it) then actually spell that out (// not lazy, value classes cannot have delegated props)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it is better like this anyhow

/**
* convenience constructor
*/
constructor(value: Asn1Sequence) : this(value.children)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here about the private primary ctor; maybe review in general which of these ctors are public vs private?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same mishap. i thought a caught all of them, but i'll re-visit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread crypto/src/commonMain/kotlin/at/asitplus/awesn1/crypto/pki/X509GeneralNames.kt Outdated
runWrappingAs(a = ::Asn1Exception) { find(ObjectIdentifier("2.5.29.18"), der)?.let(::X509GeneralNames) }

private fun List<X509CertificateExtension>.find(oid: ObjectIdentifier): List<Asn1Element>? {
private fun List<X509CertificateExtension>.find(oid: ObjectIdentifier, der: Der): List<X509GeneralName>? {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer if this was called findSingle

JesusMcCloud and others added 2 commits July 21, 2026 11:51
…9GeneralNames.kt

Co-authored-by: Jakob Heher <jakob.heher@iaik.tugraz.at>
@JesusMcCloud
JesusMcCloud requested a review from iaik-jheher July 21, 2026 13:22
Sign up for free to 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.

2 participants