PrivateRSAKeyAttributes ::= SEQUENCE {
- value ObjectValue {RSAPrivateKeyObject},
value ObjectValue,
modulusLength INTEGER, - modulus length in bits, e.g. 1024
- keyInfo KeyInfo {NULL, PublicKeyOperations} OPTIONAL,
keyInfo KeyInfo OPTIONAL,
… - For future extensions
}
PrivateECKeyAttributes ::= SEQUENCE {
- value ObjectValue {ECPrivateKey},
value ObjectValue,
- keyInfo KeyInfo {Parameters, PublicKeyOperations} OPTIONAL,
keyInfo KeyInfo OPTIONAL,
… - For future extensions
}
As you can see from the code above, I've done some modifications in order to compile it by asn1c.
The problem is that it generates only a C struct (specialization according of asn1c source code) with the PrivateRSAKeyAttributes for both privateRSAKey and privateECKey regardless of their last parameter (PrivateRSAKeyAttributes vs PrivateECKeyAttributes).
I've done some testings and only if I modify the first parameter of the type instantiation it creates a new specialization.
Reading the source, I think the problem may be located either in compare_specializations() at asn1fix_param.c, where two specializations are compared, or in asn1f_parameterization_fork() at asn1fix_param.c where a new specialization is created.
How hard is it to fix?
Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm using asn1c to compile the PKCS#15 module where there are many parameterized types, e.g.:
PKCS15Object {ClassAttributes, SubClassAttributes, TypeAttributes}
::= SEQUENCE {
commonObjectAttributes CommonObjectAttributes,
classAttributes ClassAttributes,
subClassAttributes EXPLICIT SubClassAttributes OPTIONAL,
typeAttributes EXPLICIT TypeAttributes
}
PrivateKeyType ::= CHOICE {
- privateRSAKey PrivateKeyObject {PrivateRSAKeyAttributes},
privateRSAKey PKCS15Object {CommonKeyAttributes, CommonPrivateKeyAttributes, PrivateRSAKeyAttributes},
- privateECKey PrivateKeyObject {PrivateECKeyAttributes}
privateECKey PKCS15Object {CommonKeyAttributes, CommonPrivateKeyAttributes, PrivateECKeyAttributes},
- privateDHKey PrivateKeyObject {PrivateDHKeyAttributes},
- privateDSAKey PrivateKeyObject {PrivateDSAKeyAttributes},
- privateKEAKey PrivateKeyObject {PrivateKEAKeyAttributes},
… - For future extensions
}
-PrivateKeyObject {KeyAttributes} ::= PKCS15Object {
- CommonKeyAttributes, CommonPrivateKeyAttributes, KeyAttributes}
PrivateRSAKeyAttributes ::= SEQUENCE {
- value ObjectValue {RSAPrivateKeyObject},
value ObjectValue,
modulusLength INTEGER, - modulus length in bits, e.g. 1024
- keyInfo KeyInfo {NULL, PublicKeyOperations} OPTIONAL,
keyInfo KeyInfo OPTIONAL,
… - For future extensions
}
PrivateECKeyAttributes ::= SEQUENCE {
- value ObjectValue {ECPrivateKey},
value ObjectValue,
- keyInfo KeyInfo {Parameters, PublicKeyOperations} OPTIONAL,
keyInfo KeyInfo OPTIONAL,
… - For future extensions
}
As you can see from the code above, I've done some modifications in order to compile it by asn1c.
The problem is that it generates only a C struct (specialization according of asn1c source code) with the PrivateRSAKeyAttributes for both privateRSAKey and privateECKey regardless of their last parameter (PrivateRSAKeyAttributes vs PrivateECKeyAttributes).
I've done some testings and only if I modify the first parameter of the type instantiation it creates a new specialization.
Reading the source, I think the problem may be located either in compare_specializations() at asn1fix_param.c, where two specializations are compared, or in asn1f_parameterization_fork() at asn1fix_param.c where a new specialization is created.
How hard is it to fix?
Regards.
It's nasty and hard.
A solution is redefine it as:
PrivateKeyType ::= CHOICE {
- privateRSAKey PrivateKeyObject {PrivateRSAKeyAttributes},
privateRSAKey SEQUENCE {
commonObjectAttributes CommonObjectAttributes,
classAttributes CommonKeyAttributes,
subClassAttributes EXPLICIT CommonPrivateKeyAttributes OPTIONAL,
typeAttributes EXPLICIT PrivateRSAKeyAttributes
},
- privateECKey PrivateKeyObject {PrivateECKeyAttributes}
privateECKey SEQUENCE {
commonObjectAttributes CommonObjectAttributes,
classAttributes CommonKeyAttributes,
subClassAttributes EXPLICIT CommonPrivateKeyAttributes OPTIONAL,
typeAttributes EXPLICIT PrivateECKeyAttributes
},
- privateDHKey PrivateKeyObject {PrivateDHKeyAttributes},
- privateDSAKey PrivateKeyObject {PrivateDSAKeyAttributes},
- privateKEAKey PrivateKeyObject {PrivateKEAKeyAttributes},
… - For future extensions
}
Thus removing all parameterized types.
Thanks.