ECC-step1: ASN.1 changes required for future ECC enhancements #309
No reviewers
Labels
No labels
bug
duplicate
enhancement
feature
help wanted
improve API
invalid
needs documentation
not-planned
rtfm
stale
support
wishlist
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libtom/libtomcrypt!309
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/ecc-asn1-part-minimal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
[edited by @sjaeckel]
re-work OID handlingwill be done later(c.f. https://github.com/libtom/libtomcrypt/pull/309#issuecomment-350570048)This breaks backwards compatibility as it removes
LTC_ASN1_CONSTRUCTEDandLTC_ASN1_CONTEXT_SPECIFICwhich were somehow nonsense anyways...Please review as there's some new code, biggest parts of the
der_*_custom_type.cfiles are c&p fromsequence.If you don't like some of the naming feel free to propose something better!
All comments very welcome!
@ -522,0 +526,4 @@typedef enum {LTC_ASN1_PC_PRIMITIVE = 0x0,LTC_ASN1_PC_CONSTRUCTED = 0x1,I'd say
unsigned charis inappropriate here as0is a valid context-specific tagI think we have two possibilities now:
unsigned long tag;which is taken into account when Class indicates a context-specific tag.-1indicatesinvalid/unusedif we go for possibility 2 regarding the
tag: How about starting to use<stdbool.h>? as this is clearly a boolean :-)this is a "private" function, just change the default signature and adapt all its invocations
most likely a dumb comment, but ... we're taking the
optionalflag here into account and this function is called as well fromder_encode_sequence_ex()where it is used to determine if we would BOF butder_encode_sequence_ex()itself ignores theoptionalflag...I would like to have also the following commit as a part of this PR https://github.com/libtom/libtomcrypt/pull/187/commits/6bb9661bfa1c11f9671328c508983bfbe9122cf3
I am not sure if it is worth to rename couple of things here to be more correct e.g.
enum public_key_algorithms>enum built_in_oidsPKA_DSA>LTC_OID_DSApk_get_oid>der_get_oidI first thought why not, now I think this change belongs to #187 as this would add code here which isn't used anywhere yet.
I think we should keep it like that as long there's not really a need and it still kinda completely represents the functionality :)
Do you see the need to make this public?
OID doesn't belong to DER, it's a general ASN.1 feature and it's spec'ed in X.660. As nobody knows X.660 (compared to X.509) I would propose to move
src/misc/pk_get_oid.ctosrc/pk/asn1/oid/oid_XXX.c(oid_by_pka()for now?... and still keep it private...)me neither
OK, let's solve OID stuff later. To move forward we should polish/finetune and merge this PR to develop.
yep, so let's get #335 ready and merged so we can finish this one
@sjaeckel could you please rebase
pr/ecc-asn1-part-minimalon the latestdevelop?done, doc&some tests still missing but hopefully I'll finish that in the next days
Thank you, I have also rebased other ECC branches so that now we have the following chain:
develop>pr/ecc-asn1-part-minimal(AKA ECC-step1 #309) >pr/ecc-non-asn1-part(AKA ECC-step2 #236) >pr/ecc-asn1-part(AKA ECC-step-3 #187)I still need to adjust the new import/export functions in "ECC-step-3 #187" to your new API (I mean ecc_import_openssl, ecc_export_openssl and ecc_import_pkcs8).
That should be it, please feel free to review.
@sjaeckel the following simple ASN1 sequence somehow confuses
der_decode_sequence(crash).What about to simplify this:
to something like:
I would also prefer shorter names for macros/constants (e.g. LTC_ASN1_CL_CONTEXT_SPECIFIC, LTC_ASN1_PC_CONSTRUCTED)
I'll have a look into the crash, that shouldn't happen, but even
dumpasn1hangs in an endless loop when trying to decode this andopenssl asn1parseerrors-out...proposals? TBH I prefer speaking macros/enum names instead of cryptic abbreviations, but probably someone else can come up with something better... and regarding the length... well auto-completion does the typing for me in these cases...
regarding
LTC_SET_ASN1_CUSTOM- I'll add thatI'll see what's possible, but I guess it will still be something like
Ad the ugly ASN1 sequence - it is an invalid DSA signature from wycheproof test suite, ASN.1 parser should simply reject it (BTW the current develop rejects it as expected).
Ad LTC_SET_ASN1_CUSTOM - it make sense to add only if it makes things easier/shorter, I'll try to think it over in more details. Anyway I have switched my EC improvements to the API that is currently available in this PR and it works.
My quick&dirty hack:
Another ugly sequence (again from wycheproof) of 2 integers + 2 extra zero bytes that should be rejected as
CRYPT_INPUT_TOO_LONG; however it is accepted:@sjaeckel please have a look at the
der_toolong_testtests inder_test.cThe new tests are related to
CRYPT_INPUT_TOO_LONGscenario which is IMO still not handled correctly.