Hi Andrew,
On 12/10/20 1:31 PM, Andrew Zaborowski wrote:
Add the key derivation algorithm used with PKCS#12 to pkcs5.c so that
it
can be found together with the two PKCS#5 KDFs, and so that it can also
be used when parsing of the PKCS#12 AlgorithmIdentifiers in the next
commit. This KDF is not recommended for new uses.
---
ell/pkcs5-private.h | 12 ++++
ell/pkcs5.c | 146 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+)
<snip>
+static bool utf8_to_bmpstring(const char *utf, uint8_t *out_buf,
+ unsigned int *out_len)
+{
+ unsigned int n;
+ int utflen;
+ wchar_t cp;
+ uint16_t *ptr = (uint16_t *) out_buf;
+
+ for (n = strlen(utf); n; n -= utflen, utf += utflen) {
+ if ((utflen = l_utf8_get_codepoint(utf, n, &cp)) <= 0 ||
+ cp > 0xffff)
+ return false;
So is this just a UCS2BE conversion? If so, then using l_utf8_to_ucs2be might
be clearer.
+
+ *ptr++ = L_CPU_TO_BE16(cp);
+ }
+
+ *ptr++ = 0;
+ *out_len = (uint8_t *) ptr - out_buf;
+ return true;
+}
+
Regards,
-Denis