1

(3 replies, posted in wolfCrypt)

Hi m_u_h,

Yes, that is correct.  If you are using wolfCrypt FIPS, wolfEngine will by default use all three checks listed above.  You would only need to override "enable_fips_checks" if you wanted to use a subset of the default options.

Keep in mind that these FIPS checks only apply to the scenarios listed above.  Applications consuming OpenSSL with wolfEngine and wolfCrypt FIPS still need to be cautious not to call/use non-FIPS validated cryptography if trying to remain FIPS compliant.  If an application calls an algorithm that is unsupported by wolfCrypt FIPS (thus unsupported in FIPS mode), OpenSSL may re-route that algorithm to the underlying non-FIPS validated OpenSSL cryptography.

Best Regards,
Chris

2

(3 replies, posted in wolfCrypt)

Hi m_u_h,

wolfEngine FIPS checks only have an effect when using a FIPS validated (or FIPS Ready) version of wolfSSL/wolfCrypt under wolfEngine.

These "FIPS checks" are checks inside wolfEngine to help make sure the caller doesn't use non-FIPS modes or key lengths of some algorithms, including:

- Check that RSA key sizes are valid. For wolfCrypt FIPS, 1024-bit RSA keys can only be used for verification, not generation or signing.
- Check that RSA signatures with SHA-1 digests are valid. For wolfCrypt FIPS, SHA-1 isn't allowed for signing, only for verifying.
- Check that ECC P-192 usage is valid. For wolfCrypt FIPS, ECC P-192 isn't allowed for ECDH, key generation, or signing. Only allowed for signature verification.

By default, if using a FIPS validated version of wolfCrypt these checks are on by default.  The "enable_fips_checks" control command lets users override the default of all being enabled, and can pass a bitmask of available options from "include/wolfengine/we_fips.h".

Are you using a FIPS validated version of wolfCrypt with wolfEngine?

Thanks,
Chris

Hi Anika,

wolfCrypt's CMS/PKCS#7 API's do not currently have the ability to extract signer certificates without calling wc_PKCS7_VerifySignedData() first.  This API parses the CMS/PKCS#7 bundle ASN.1 and extracts details into our own wolfCrypt structure, in addition to then trying to verify the signature.  If you did not care about the verification result, you could call this API, check/ignore the return value of SIG_VERIFY_E, then proceed to get the signer certificates from the pkcs7->certs[] array, using the pkcs7->certSz[] size array for array sizes.

Pseudocode would look something similar to:

ret = wc_PKCS7_VerifySignedData(pkcs7, in, inSz);
if (ret < 0 && ret != SIG_VERIFY_E) {
    /* other error, parsing, etc */
}

/* loop over pkcs7->cert[], where pkcs7->certSz[] holds sizes for each cert */
for (i = 0; i < MAX_PKCS7_CERTS; i++) {
    if (pkcs7->certSz[i] > 0) {
        /* pkcs7->cert[i] holds ith cert from SignedData bundle */
    }
}

Best Regards,
Chris

Hi Anika,

Let me look into this and I'll get back to you shortly.

Thanks,
Chris

Hi Renjith,

Were you able to try the SP math build options to see if that helped improve performance?

Thanks,
Chris

Hi Renjith,

For ECDSA, public certificate loading had issues with wolfcrypt JCE

Are you able to share more details on the error that you saw for this?  Or, would it be easy to send over a simple sample app that reproduces the issue?  If so, I can help look into this further.  This may be due to a native build option that needs to change, or a higher-level JCE feature depending on the error.

Are there any flags to improve the signing performance(perhaps for making use of the native code)?

We have several different math libraries available in native wolfSSL now that provide varying performance and features.  We have our normal big integer library, our fastmath library, and our newest SP Math library.  On most platforms, fastmath will be the default.  Switching over to our newer SP Math should give you performance increases for public key operations (RSA, ECDSA).

If you are uisng configure with wolfSSL, you can try the following options:

./configure --enable-sp --enable-sp-math-all <other options>

Our SP Math library does also have assembly optimizations for several platforms.  Depending on your target hardware, you may be able to add --enable-sp-asm to the above options.

Let me know if that builds OK, and what you see as far as performance goes.

Thanks!
Chris

Hi realexan,

Thanks for reaching out.  We have not tested wolfJSSE or wolfJCE with Nimbus JOSE + JWT before in-house.  Can you confirm, are you are using wolfJSSE or our cryptography provider wolfJCE?  I am not familiar enough at the moment with how Nimbus JOSE + JWT calls down into the Java Security Architecture to know if it is calling into a JCE or JSSE provider.  If you are using wolfJSSE (wolfSSL JNI/JSSE Provider), it may be worth trying to download, build, and register our JCE provider (wolfCrypt JNI/JCE) to see if that gives Nimbus access to the algorithm primitives that it is expecting.

Native wolfSSL supports RSA 2048 and SHA-256, as does wolfJSSE (in TLS cipher suites) and wolfJCE (via Signature and MessageDigest classes).

Are you able to provide more details about the project you are working on, and why you are looking to use wolfJSSE/wolfJCE in place of the default cryptography providers?

Thanks,
Chris

Hi Beat,

I'm not sure that I am following the reasoning behind needing to reset "ret = 0" at that location in pkcs7.c.  It is expected behavior that "ret" would be set to ASN_PARSE_E in the following section of code for your use case, since tag != ASN_OCTET_STRING:

            /* get length of content in case of single part */
            if (ret == 0 && !multiPart) {
                if (tag != ASN_OCTET_STRING)
                    ret = ASN_PARSE_E;

                if (ret == 0 && GetLength_ex(pkiMsg, &localIdx,
                            &length, pkiMsgSz, NO_USER_CHECK) < 0)
                    ret = ASN_PARSE_E;
            }

Later on, we enter the "else" block like you mentioned above, where "detached" gets set to 1, "length" to 0, and "contentLen" to 0.  The next time "ret" is checked is inside the "#ifndef NO_PKCS7_STREAM" section right below that, where:

            /* content expected? */
            if ((ret == 0 && length > 0) &&
                !(pkiMsg2 && pkiMsg2Sz > 0 && hashBuf && hashSz > 0)) {
                pkcs7->stream->expected = length + ASN_TAG_SZ + MAX_LENGTH_SZ;
            }

Here, the value of "ret" won't matter since "length" has already been set to 0.  Then, just a little below that, we reset the value of "ret" with the following call:

            if ((ret = wc_PKCS7_StreamEndCase(pkcs7, &stateIdx, &idx)) != 0) {
                break;
            }

I re-ran your reproducer application against wolfSSL (current master), after making the following changes and verification passed successfully without the additional reset of "ret".  Changes to main.c:

1.  Removed setting "pkcs7.content" and "pkcs7.contentSz" explicitly. No longer needed for this use case after our previous modifications.
2.  Switched wc_PKCS7_VerifySignedData() to "wc_PKCS7_VerifySignedData_ex(), passing in "shaSumOfBinary".

I have re-attached the reproducer bundle I am using here.  Steps I am using to compile/test are:

$ git clone https://github.com/wolfSSL/wolfssl.git
$ cd wolfssl
$ ./autogen.sh
$ ./configure --enable-pkcs7
$ make
$ sudo make install

$ unzip signature_and_binary_v2.zip
$ cd signature_and_binary_v2
$ gcc main.c -lwolfssl
$ ./a.out -s 4dda5fe7-55d8-481a-b6eb-cf74b1b58d4d-d319ae60-1645-42b9-a9c0-eca4395587be.bin -b test.bin

calculated SHA256 of test.bin
56 d3 bb f1 e0 a9 27 b6 57 ba 90 ea 7d c0 ec e6 
ba 60 22 39 f0 ac 00 ad 8b 87 96 af ad 20 d1 40 
Sucessfully verified

Let me know if you think I'm still overlooking something, but this looks to be working as expected for this code path to me.

Thanks,
Chris

Hi Kevin,

Can you try defining SIZEOF_LONG and SIZEOF_LONG_LONG in your CFLAGS when compiling wolfSSL in AOSP?  This would typically be located in your Android.mk file for wolfSSL (external/wolfssl/Android.mk).  The values of these should match sizeof(long) and sizeof(long long) on your system.  These are typically 4 and 8 respectively.

For example:

LOCAL_CFLAGS:=-DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 <other options>

Thanks,
Chris

Hi Beat,

I have put up a small fix in the following Pull Request to wolfSSL that should fix your use case:

https://github.com/wolfSSL/wolfssl/pull/3996

Testing here with your sample app, with this change, your signature correctly verifies with wc_PKCS7_VerifySignedData_ex().

Best Regards,
Chris

Hi Beat,

Thanks for the clarification.  I now see your desire/need to pass in only the pre-computed digest of the content rather than the content itself.

Let me revisit our wc_PKCS7_VerifySignedData_ex() code and I'll get back to you shortly.

Thanks,
Chris

Hi Beat,

I had a chance to look over your examples and believe you may have just been mis-using the wc_PKCS7_VerifySignedData API for use with detached signatures.

wc_PKCS7_VerifySignedData() can verify detached signatures, but your application needs to explicitly set the content and content size using the "pkcs7.content" and "pkcs7.contentSz" structure members before doing the verification.

Internally in pkcs7.c we do some detection of empty content in the PKCS#7/CMS bundle and purposefully set our internal error state to ASN_PARSE_E.  But, we recover from that error state later on once we realize the user has set the pkcs7.content and pkcs7.contentSz correctly.

I have attached a modified version of your main.c (here as main_verifySignedData.c) where I explicitly set these two struct members before doing the verification.  Compiling this against the current version of wolfSSL, I am seeing a verification success.

I did also change wc_PKCS7_VerifySignedData_ex() to the normal wc_PKCS7_VerifySignedData() in your sample application.  wc_PKCS7_VerifySignedData_ex() requires as inputs the PKCS#7/CMS "head" and "foot" as inputs that would have been received as outputs from the corresponding call to wc_PKCS7_EncodeSignedData_ex().  My guess was that you did not have these available and meant to use wc_PKCS7_VerifySignedData() instead.  But, please correct me if I am wrong.  wc_PKCS7_VerifySignedData() also handles calculation of the message digest internally, so I removed that logic from your sample code.

Best Regards,
Chris

Hi bstraehl,

Thanks for attaching your test application.  We'll look into this and get back to you shortly.

Best Regards,
Chris

14

(1 replies, posted in wolfSSL)

Hi,

Yes, wolfCrypt PKCS#7 API can be used to decode a p7b certificate and extract out an X.509 certificate.

You will want to use wc_PKCS7_Init() to initialize a PKCS7 structure, then use wc_PKCS7_VerifySignedData() to decode the p7b certificate.  wc_PKCS7_VerifySignedData() will place decoded X.509 DER-encoded certificates into the pkcs7->cert array, with the size of each stored in the pkcs7->certSz array.

The following GitHub Issue has more details on API usage:

https://github.com/wolfSSL/wolfssl/issues/3638

Can you share more details about the project you are looking to use wolfCrypt in?

Thanks,
Chris

Hi!

This looks like a duplicate posting from the following GitHub Issue.  Please see response on the GitHub issue for a resolution:

https://github.com/wolfSSL/wolfssl/issues/3638

Thanks,
Chris

Hi thomas.zeng,

wolfCrypt's PKCS#7/CMS implementation doesn't have support for CAdES-BES currently.  This is something our team could look into adding for you if needed, under our consulting services.  We would need to add re-implement CMS CAdES-BES support ourselves in wolfCrypt instead of porting the pull request you mentioned, for licensing reasons.

wolfSSL does have an OpenSSL compatibility layer which includes a large number of the most commonly-used OpenSSL API.  Our compatibility layer does have some OpenSSL PKCS7 API support, which can be seen in the <wolfssl/openssl/pkcs7.h> header file:

https://github.com/wolfSSL/wolfssl/blob … sl/pkcs7.h

We don't yet have the CMS_sign() API wrapped yet, or the CMS_ContentInfo structure.  It looks like there may be some work required to fill out missing OpenSSL CMS API support if you would require that.  Another route would be to switch to the wolfCrypt PKCS7/CMS API instead of using the OpenSSL compatibility layer.

Is this something you would be interested in exploring further?

Best Regards,
Chris

The spring release of wolfSSL, v4.4.0, is now available! This release has many new features, optimizations, and bug fixes. Some of the new features we added to the wolfSSL embedded SSL/TLS library include:

  • Qualcomm Hexagon SDK support.

  • DSP builds to offload ECC verify operations.

  • Certificate Manager callback support.

  • New APIs for running updates to ChaCha20/Poly1305 AEAD.

  • Support for use with the Apache web server.

  • Add support for IBM s390x.

  • PKCS8 support for ED25519.

  • OpenVPN support.

  • Add P384 curve support to SP.

  • Add BIO and EVP API.

  • Add AES-OFB mode.

  • Add AES-CFB mode.

  • Add Curve448, X448, and Ed448.

  • Add Renesas Synergy S7G2 build and hardware acceleration.

Check out the README from the download for a full list of features and fixes, or contact us at facts@wolfssl.com with any questions:
https://github.com/wolfSSL/wolfssl/blob … /README.md

Download wolfSSL 4.4.0:
https://www.wolfssl.com/download/

Hi vaslion18,

Yes, wolfSSL can be used on Android for secure SSL/TLS communication.  We typically see Android users use wolfSSL through our JNI layer, since most applications are written in Java.  But, if you are only looking to use wolfSSL at the native C level on Android, you will be able to directly call native wolfSSL API.

wolfSSL itself is only an SSL/TLS layer, and does not include any HTTP functionality.  You would need to have other logic, or libraries for HTTP, but could route those through wolfSSL for SSL/TLS.

For getting wolfSSL compiling and running on Android, you may be able to reference some of our example projects here:
https://github.com/wolfSSL/wolfssl-exam … er/android

These example projects use our JNI wrappers, but you may be able to use the examples as reference for compiling the native wolfSSL library.  I believe you will need to re-compile wolfSSL for each unique Android architecture you are using.

If you have any additional questions, feel free to ask, or email our support team directly at support@wolfssl.com.

Best Regards,
Chris

19

(0 replies, posted in cURL)

wolfSSL has been working with Daniel Stenberg to create tiny-curl, a lightweight version of the cURL library which has a much smaller footprint than the full featured library.  This will be ideal for embedded or resource constrained users who want to use cURL in their projects!

Full details can be found on Daniel's blog [1].  As Daniel mentions in this blog post:

Instead of being happy with getting told that curl is “too big” for certain use cases, I set a goal for myself: make it possible to build a version of curl that can do HTTPS and fit in 100K (including the wolfSSL TLS library) on a typical 32 bit architecture.

As a comparison, the tiny-curl shared library when built on an x86-64 Linux, is smaller than 25% of the size as the default Debian shipped library is.

tiny-curl can be downloaded from the wolfSSL download page [2] today!  Please email us at support@wolfssl.com with any questions or commercial support inquiries.

[1] https://daniel.haxx.se/blog/2019/05/11/tiny-curl/
[2] https://www.wolfssl.com/download/

20

(0 replies, posted in cURL)

wolfSSL offers commercial support for cURL!

The wolfSSL embedded SSL/TLS library comes with support for many tools and libraries, one of which is cURL (https://curl.haxx.se/). cURL is a software project that produces two products (libcurl and curl), used for transferring data using various protocols. wolfSSL is happy to announce that we are now offering commercial support and maintenance for cURL!  In addition, Daniel Stenberg (an original author of cURL and one of the founders) is now part of the wolfSSL team.

If you are interested in learning more about commercial cURL support from wolfSSL, please contact us at facts@wolfssl.com.

Best Regards,
Chris

https://www.wolfssl.com/wolfssl-integra … ltinycurl/

21

(0 replies, posted in cURL)

Welcome to wolfSSL's cURL / libcurl / tinycurl forum.  Please submit any questions, comments, feature requests, or anything else related to cURL here.

Did you know that wolfSSL provides commercial support for cURL?  Learn more here:

https://www.wolfssl.com/products/curl/

Best Regards,
Chris

Hi jlagerquist,

Thanks for the suggestion!  We now have a wolfBoot forum:

https://www.wolfssl.com/forums/forum11-wolfboot.html

Best Regards,
Chris

Hi srikbn,

The output you mentioned is expected when you have compiled wolfSSL with "--enable-debug" or -DDEBUG_WOLFSSL.  This is being output by the wolfCrypt test app when a failure test case is being tested and is expected.

Best Regards,
Chris

Hi pkolte,

Thanks again for bringing this issue to our attention.  This will be fixed in the next release of wolfSSL JNI.  We are currently working on a substantial improvement to wolfSSL JNI with the addition of a JSSE provider.  This has been fixed as part of that effort.  You will no longer need to worry about size limitations when calling WolfSSLSession.write().

Thanks,
Chris

25

(5 replies, posted in wolfSSL)

Hi rahuld3919,

If you are trying to connect to a server that has a self-signed certificate (server cert is signed by itself), you have two options:

1)  Load the same server certificate into the client as a trusted root certificate.  You can do this using the wolfSSL_CTX_load_verify_locations() API.

2)  Disable peer verification using the wolfSSL_CTX_set_verify() with SSL_VERIFY_NONE.  This will disable verification, and is not recommended.

Best Regards,
Chris