Commits on Source (69)
-
Alexander Scheel authored
Assert._assert is probably a relic from an older era. The class incorrectly identifies them as "C-style assertions": the assert keyword is actually closer to "C-style assertions" as they require the explicit flag "-ea" (or "-enableassertions") to be passed to the JVM, similar to how DEBUG needs to be defined for assert(...) to work in C. In two places, where Assert._assert(false, msg) was called, I've instead chosen to directly raise an org.mozilla.jss.util.AssertionException. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
NSS on s390x seems to ignore the semantics of async io/EWOULDBLOCK: rather than retrying the failing write, it drops the data and refuses to continue. This manifests itself as RSA-based TLS handshakes failing, because the certificate and associated packets exceeded the size of the internal buffer (2048). Bumping the buffer for the tests to 4096 plasters over the issue (so long as we only include one certificate and not the entire chain). redhat-bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1730109 Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This mirrors the behavior of the environment variable. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When NSS is built without FIPS mode, enabling FIPS mode fails. The output from CryptoManager is non-obvious (it states that it fails but doesn't passthrough the underlying NSS error). Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
The old build system supported building NSPR, NSS, and JSS together. This facilitated testing changes across all three. This iteration for the new build system requires you to build NSS separately according to the build method of your choice. To use, set the SANDBOX option or set the SANDBOX environment variable: cd sandbox/nss && ./build.sh -g --enable-fips cd ../jss/build && SANDBOX=1 cmake .. && make && ctest Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Elio Maldonado authored
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
The CMS provider differs from the SUN provider; it only provides a few X509-related operations. It is also used in CMSEngine in PKI, though its functionality could be exposed from Mozilla-JSS in the future if we desire. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This is better suited for NSS via the Mozilla-JSS provider. This entire provider could eventually be removed if we wished, but certain functionality required by PKI transitively depends on it. It is never explicitly added though, so I'm not convinced those places truly use it via the intended APIs. However, various classes inside the provider are used directly (such as RSAPublicKey and DSAPublicKey). Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Naming a file "buffer.h" on MacOS has the unfortunate consequence of conflicting with other includes. Rename our copy to j_buffer.h to avoid this problem. Reported by @c42-arthur in issue #226. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
PRBufferGetSocketOption takes two parameters: the PRFileDesc that we're operating on and a PRSocketOptionData where we place the result. I incorrectly treated this as a struct holding all options for a socket. In reality, it contains two fields: - the option requested - the value of that option (via a union) We thus need to condition on the option requested and return *only* its value. Under the previous implementation, we clobbered all options we set, except the last one, data->value.send_buffer_size. In TestBufferPRFD.c, we set the capacity of the buffer as 2048. Since sizeof(PRSize) >= sizeof(PRBool), we did not perform an out of bounds write. On big endian systems such as s390x, we stored the value 0x00000000 00000800: this meant accessing data->value.non_blocking returned PR_FALSE (0x00). Since the condition in ssl_FdIsBlocking is "!opt.value.non_blocking", this resulted in NSS assuming our buffer was blocking. Many thanks to Bob Relyea for finding this. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1730109 Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This move lets us put direct test for the Buffer PRFileDesc implementation in a new file called TestBufferPRFD, keeping the SSL tests separate. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
There are two issues with debug builds in JSS right now: a number of comparisons between unsigned variables and signed literals, and a use of a potentially uninitialized variable due to an incorrect conditional and late variable declaration. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When executing the tests in a debug build, TestBufferPRFD aborts because PR.Write isn't defined for Buffer backed PRFileDesc's. Even though it isn't strictly required for SSLEngine support, implementing it is easy (using Send/Recv). Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
CMake's foreach() construct doesn't use "in" as a separator between the iterated variable and the list. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This test exercises the ECPublicKey and ECPrivateKey interfaces that are newly added to the public/private key classes in org.mozilla.jss.pkcs11. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
The JDK internally maintains a database of curves (called the CurveDB); only some of these curves are used by the Sun provider and are internally called "named" curves. However, this curve database isn't exposed to the public. Unlike the JDK, we expose our curve database for other providers to use. Currently we only maintain a mapping between names, oids, and curve parameters. We should eventually extend it to replace all curve usages in PK11KeyPairGenerator; this will likely involve moving the contents of ECCurve_Code over as well. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
We introduce the jss.util.EC class for helper functions for decoding NSS EC key information. This includes a point decoder helper and an OID to curve parameters helper. Future work includes expending decodeNSSPoint to handle compressed and hybrid point encoding forms. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
With the new curve database and the NSS helpers, we can now implement the standard ECPublicKey interface from our PK11ECPublicKey class, bringing JSS into compliance. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Since NSS exposes SECKEY_ConvertToPublicKey(...), we can convert our private key pointer to a public key pointer and re-wrap it as a PK11PubKey instance (of the correct subtype). This lets us implement ECPrivateKey's getParams() interface via ECPublicKey's implementation. Note that getS() won't be supported due to limitations in NSS. Futher work will need to be done to expose the private key values to the caller for this (and the interfaces for other key types) to function. Additionally, returning the private key data might not always be possible, e.g., when the key lives on an HSM. This means that we're still restricted to working only with JSS-based encryption methods for the large part. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
The standard Java interface for EC key pair generation only includes a name. Use the ECCurve enum to resolve this to an OID for use by NSS. A similar patch was initially proposed by Andrew Helgeson (@ZuluForce) in upstream issue https://github.com/dogtagpki/jss/issues/226 . Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Stanislav Levin authored
- The names of outdated parameters were corrected or removed. - Code blocks were escaped with {@code text} and {@literal text}. - Missing html tags were added. Fixes: https://github.com/dogtagpki/jss/issues/246 Signed-off-by:
Stanislav Levin <slev@altlinux.org>
-
Alexander Scheel authored
One documents parameters that were removed from a previous PR because they didn't match the function signature. I've readded those. The other re-adds two placeholders for clarity, using @literal this time. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When building JSS, our test suite requires the rest of the JSS JAR to be built. Previously however, our build system didn't reflect that dependency correctly, causing the build to fail on some platforms. Related: #254 Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Per report by Magnus Karlsson on pki-devel@redhat.com, KeyStoreTest is bad example code because it doesn't actually work. In particular, it fails to initialize a KeyStore instance correctly (passing only the name of the provider and not the name of the KeyStore type we want). Fix the test and re-add it to the test suite. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This includes the new CKM_AES_CMAC and CKM_AES_CMAC_GENERAL constants. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This tests the latest upstream NSPR and NSS from Mozilla, on the latest Fedora rawhide container, and ensures that we can build and pass our current test suite. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
run_test.sh.in is templated by CMake to build/run_test.sh, fully configured to your test execution environment. In particular, it writes the classpath and loads the JSS native library. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When given an NSS DB, common_roots.sh uses the trust command to extract the root CAs trusted by the local system and add them to said NSS DB. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When the SHA-2 variants were initially added (SHA2-256, SHA2-384, and SHA2-512), they weren't added to either SymmetricKey or PKCS11Algorithm. This fixes that, allowing Algorithm identifiers to be mapped to PKCS11Constant values, and also to be used as symmetric keys. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Each usage in SymmetricKey.Usages maps to a specific PKCS11Constant with prefix "CKA_" (which is of type CK_ATTRIBUTE_TYPE). These constants can be directly used with the underlying PKCS#11 interface via JNI. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This reverts commit a52de916. This commit isn't necessary: while the tests depend on the rest of JSS, javac will detect the necessary files (because of -sourcepath) and continue with the build. In fact, build order is a red herring: the real issue is that the org.mozilla.jss.pkix package namespace is empty, so: import org.mozilla.jss.pkix.*; won't have any classes to import. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Under the javac shipped in RHEL 7, we see the following error when building the test suite: jss/org/mozilla/jss/tests/TestBufferPRFD.java:8: error: package org.mozilla.jss.pkix does not exist import org.mozilla.jss.pkix.*; ^ This is because the org.mozilla.jss.pkix namespace doesn't include any classes; it only contains sub-packages. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Off of a SSL-enabled PRFileDesc created by NSS's SSL_ImportFD, we might want to store various information which would be helpful (and, necessary to free at the end): - Any TrustManagers we're using on this connection, - Whether or not the handshake has finished, - The client certificate, or - Additional parameters required for NSS callbacks. Some of these will be Java-backed values, in which case they should be added directly to SSLFDProxy. Others will be C-backed values, in which case they should be freed once the SSL Socket is closed. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
In org.mozilla.jss.nss.SSL, we've retyped all methods to take SSLFDProxy instead of PRFDProxy where appropriate. This will let future native methods access any fields we place on the SSLFDProxy. We've also updated the existing tests to use SSLFDProxy instead of PRFDProxy where appropriate. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
We're previously given the option to either install the JSS provider or not, and optionally to remove the Sun Provider. Users can re-order the providers later if they want, but the most common other option will be to only use JSS for specified operations. To achieve this, we put JSS as the very last provider. Hence, add: installJSSProviderFirst = true as a new value in InitializationValues. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Sometimes we have only a single CERTCertificate but wish to inquire about as much of its chain as we can, and return the result as a jobjectArray to pass back to Java. This is helpful when we've gotten a CERTCertificate from NSS and we need to check it against a TrustManager instance. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Often we'll need to take a PRErrorCode and raise it as a Java Exception (via the JNI interface) of the proper type. Other times, we'll need to take a raised Java Exception and return it as the correct (SECStatus, PRErrorCode) pair. We introduce JSS_ExceptionToSECStatus and JSS_SECStatusToException to handle this. The latter has a *Message form, which takes an error message to raise with the exception. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
ImportDERCert differs from other calls in that it allows importing a certificate temporarily, without putting it in the permanent trust store. This lets you import (and trust) an intermediate CA certificate without permanently storing it, and use it to validate a leaf certificate. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
We extend the existing VerifyCertificate logic to include support for validating a certificate by reference (e.g., an instance of X509Certificate) instead of purely by nickname. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
By exposing the value of ocspPolicy from the CryptoManager (instead of the ordinal, which we'd have to convert back to an enum for most calls), we can more easily support save/restore operations for the value of OCSP policy. This will enable, in combination with the previous patch, explicit OCSP checks on certificates and their chains, restoring the current policy afterwards. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
In 871231d2 I incorrectly handled an unused variable warning, where rc is unused when compiling outside of debug mode. As part of this fix, I incorrectly returned based on the same values we were asserting -- for 3 of the 4 values. Instead, I should've returned when these conditionals were negated. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Since we're building NSS in debug mode by default, we should also build JSS in debug mode here. This will be our only build with CMake release type DEBUG and debug CFLAGS. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
CMAC is a form of MAC that utilizes a block cipher instead of a hash function. Support for CMAC via PKCS#11 was recently introduced to NSS allowing us to add support for it here. Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1570501 Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
These tests are from NIST's Examples with Intermediate Values page: https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
JSSMacSpi differs from JSSCipherSpi in that it requires the caller to pass a SecretKeyFacade instance (which merely wraps a SymmetricKey) and are typically created by SecretKeyFactory. However, the caller might have an existing SymmetricKey and wish to use that with JSSMacSpi; check for that case and handle it gracefully. Unlike JSSCipherSpi, we don't use the SecretKeyFactory to clone the underlying key. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
We add support for handling the client certificate callback via a fixed client certificate. This lets us specify ahead of time which client certificate we wish to use and return it when asked by NSS. Setting the client certificate on the SSLFDProxy is done via: SSLFDProxy.SetClientCert(...) And telling NSS to use this certificate is done via: SSL.EnableClientAuthentication(...) Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
We extend the default NativeProxy implementation in three directions: - Make it AutoCloseable, - Add a clear() method which supports clearing the value of the pointer without calling releaseNativeResources(...), and - Save a stack trace when assertions are enabled. By implementing AutoCloseable, we enable the common Java pattern of try-with-resources: try (NativeProxy item = ...) { ... } and have the item automatically be closed (in our case, finalized(...)) at the end of its life cycle. We've added additional logic to prevent double-free bugs. Additionally, by adding clear(...), we both add protection from double-free bugs and enable resource cleanup from native handlers that removes entries in NativeProxy's internal tracking. Lastly, we save stack traces when assertions are enabled in the JVM and JSS is built in DEBUG mode (with DEBUG defined). Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
On CMake versions less than 3.12.0 (shipped July 17, 2018), the list(...) helper lacks the JOIN subcommand. We use this for joining the C compiler flags into CMAKE_REQUIRED_FLAGS for symbol detection. This introduces a shim for older systems lacking these useful macros, including RHEL 8. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This ASSERT_OUTOFMEM(env) is incorrect for two reasons: 1. When JSS_RefByteArray detects a zero-length result, it returns false but doesn't throw an exception. It is up to the caller to handle that as they wish. In our case, we can safely skip the PK11_DigestOp call. 2. When length < offset+len (and JSS_RefByteArray exits successfully), we won't have thrown an exception. This only shows up in debug builds; release builds aren't affected. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
When the Leaf and Chain OCSP checking policy is enabled in CryptoManager, JSS will switch to alternative certificate verification logic in JSSL_DefaultCertAuthCallback. In this method, the root certificate was incorrectly trusted without being verified to exist in the trust store. This patch cleans up the logic in JSSL_verifyCertPKIX and makes it more explicit in addition to fixing the error. Fixes CVE-2019-14823 Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
badssl.com maintains a number of subdomains with valid and invalid TLS configurations. A number of these test certificates which fail in certain scenarios (revoked, expired, etc). Add a test runner which validates SSLSocket's implementation against badssl.com. Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Alexander Scheel authored
This version of JSS has a security fix: - CVE-2019-14823: Fix root certificate validation when using Leaf and Chain OCSP mode This version of JSS also has a few enhancements over v4.6.1: - Fixing JSS internal deprecation warnings by @emaldona - Fixing javadoc builds by @stanislavlevin - Introduce a new InitializationValue, installJSSProviderFirst, to support favoring other cryptographic providers. - Add support for CMAC as a Mac algorithm from JSSProvider; note that this requires JSS to be compiled with a NSS release which also supports CMAC (3.47+). - Various improvements to the Key APIs. Thanks to everyone who contributed to this release! Signed-off-by:
Alexander Scheel <ascheel@redhat.com>
-
Timo Aaltonen authored
-
Timo Aaltonen authored
-
Timo Aaltonen authored
-
Timo Aaltonen authored
cmake/Shims.cmake
0 → 100644
debian/patches/fix-bufferprfd.diff
deleted
100644 → 0