add pin-source feature for pkcs11 uri#236
Conversation
|
Hi, Could you review this PR? |
|
I promise I will. Just give me a few days. |
|
Thank you. |
mtrojnar
left a comment
There was a problem hiding this comment.
I like the idea, the implementation, and the coding style consistency.
There are however two RFC 7512 requirements that remain unimplemented:
- Refusing of using both pin-source and pin-value (Section 2.4).
If a URI contains both "pin-source" and "pin-value" query attributes, the URI SHOULD be refused as invalid.
This requirement should be fairly easy to implement by refusing to parse pin-set and pin-source if pin_set
is already set to 1.
- Path normalization (Section 2.6).
The value of "pin-source", if containing a "file:" URI or "|", MUST be compared using the simple string comparison after the full syntax-based normalization, as specified in Section 6.2.2 of [RFC3986], is applied. If the value of the "pin-source" attribute is believed to be overloaded, the case and percent-encoding normalization SHOULD be applied before the values are compared, but the exact mechanism of comparison is left to the application.
|
I second that and would like to add, that you shouldn't use |
|
@frankmorgner Yes, |
|
AFAIK, there is no clear oversight on how libp11 (engine and library) is actually used. So likely or not, we should prevent problems when seeing them. Programmer's laziness or lack of specification are no good excuses. |
|
@frankmorgner What I meant was not "I am too lazy to implement a proper solution", but rather "I think that a complex (and thus error-prone) solution to fix a problem that unlikely to occur would do more harm than good here". This is just my opinion and I understand and appreciate your point of view. |
|
I agree with @mtrojnar that
@frankmorgner Could you suggest an alternative solution for |
…rmalization by comparing case insentive
| return 1; | ||
| } | ||
|
|
||
| static int strnicmp(const char *cs, const char *ct, size_t count) |
There was a problem hiding this comment.
have you tried strncasecmp()?
|
An alternative to Anyway, if you still want to use |
|
This pull request introduces 1 alert when merging a659aba into 97700cb - view on LGTM.com new alerts:
Comment posted by LGTM.com |
src/eng_parse.c
Outdated
| { | ||
| FILE *fp; | ||
|
|
||
| fp = fopen(path, "r"); |
There was a problem hiding this comment.
could use OpenSSL's bio methods
|
@Ortigali an alternative to popen is suggested in the man page (linked above with http://manpages.ubuntu.com/manpages/trusty/en/man3/popen.3posix.html#rationale) |
This is a modified version of original PR: OpenSC#236
According to https://tools.ietf.org/html/rfc7512#page-9: """ 2.4. PKCS OpenSC#11 URI Scheme Query Attribute Semantics An application can always ask for a PIN by any means it decides to. What is more, in order not to limit PKCS OpenSC#11 URI portability, the "pin-source" attribute value format and interpretation is left to be implementation specific. However, the following rules SHOULD be followed in descending order for the value of the "pin-source" attribute: o If the value represents a URI, it SHOULD be treated as an object containing the PIN. Such a URI may be "file:", "https:", another PKCS OpenSC#11 URI, or something else. o If the value contains "|<absolute-command-path>", the implementation SHOULD read the PIN from the output of an application specified with absolute path "<absolute-command- path>". Note that character "|" representing a pipe does not have to be percent-encoded in the query component of a PKCS OpenSC#11 URI. o Interpret the value as needed in an implementation-dependent way. """ This patch is based on: OpenSC#236, but implements only the first clause of RFC, since the second one is considered as dangerous. For example, such functionality is required by FreeIPA (Bind + OpenDNSSEC). Fixes: OpenSC#273 Co-authored-by: Ortigali Bazarov <ortigali.bazarov@gmail.com> Signed-off-by: Stanislav Levin <slev@altlinux.org>
According to https://tools.ietf.org/html/rfc7512#page-9: """ 2.4. PKCS OpenSC#11 URI Scheme Query Attribute Semantics An application can always ask for a PIN by any means it decides to. What is more, in order not to limit PKCS OpenSC#11 URI portability, the "pin-source" attribute value format and interpretation is left to be implementation specific. However, the following rules SHOULD be followed in descending order for the value of the "pin-source" attribute: o If the value represents a URI, it SHOULD be treated as an object containing the PIN. Such a URI may be "file:", "https:", another PKCS OpenSC#11 URI, or something else. o If the value contains "|<absolute-command-path>", the implementation SHOULD read the PIN from the output of an application specified with absolute path "<absolute-command- path>". Note that character "|" representing a pipe does not have to be percent-encoded in the query component of a PKCS OpenSC#11 URI. o Interpret the value as needed in an implementation-dependent way. """ This patch is based on: OpenSC#236, but implements only the first clause of RFC, since the second one is considered as dangerous. For example, such functionality is required by FreeIPA (Bind + OpenDNSSEC). Fixes: OpenSC#273 Co-authored-by: Ortigali Bazarov <ortigali.bazarov@gmail.com> Signed-off-by: Stanislav Levin <slev@altlinux.org>
According to https://tools.ietf.org/html/rfc7512#page-9: """ 2.4. PKCS #11 URI Scheme Query Attribute Semantics An application can always ask for a PIN by any means it decides to. What is more, in order not to limit PKCS #11 URI portability, the "pin-source" attribute value format and interpretation is left to be implementation specific. However, the following rules SHOULD be followed in descending order for the value of the "pin-source" attribute: o If the value represents a URI, it SHOULD be treated as an object containing the PIN. Such a URI may be "file:", "https:", another PKCS #11 URI, or something else. o If the value contains "|<absolute-command-path>", the implementation SHOULD read the PIN from the output of an application specified with absolute path "<absolute-command- path>". Note that character "|" representing a pipe does not have to be percent-encoded in the query component of a PKCS #11 URI. o Interpret the value as needed in an implementation-dependent way. """ This patch is based on: #236, but implements only the first clause of RFC, since the second one is considered as dangerous. For example, such functionality is required by FreeIPA (Bind + OpenDNSSEC). Fixes: #273 Co-authored-by: Ortigali Bazarov <ortigali.bazarov@gmail.com> Signed-off-by: Stanislav Levin <slev@altlinux.org>
|
I merged #309 instead of this PR. |
Implement "pin-source" attribute using below specs
https://tools.ietf.org/html/rfc7512#page-9