Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto
AgeCommit message (Collapse)Author
2016-08-01Fix mixed comment markers.David Benjamin
We managed to mix two comment styles in the Go license headers and copy-and-paste it throughout the project. Change-Id: Iec1611002a795368b478e1cae0b53127782210b1 Reviewed-on: https://boringssl-review.googlesource.com/9060 Reviewed-by: Steven Valdez <svaldez@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-29Add |BN_mod_inverse_blinded| and use it in RSA blinding.Brian Smith
Yo dawg I herd you like blinding so I put inversion blinding in your RSA blinding so you can randomly mask your random mask. This improves upon the current situation where we pretend that |BN_mod_inverse_no_branch| is constant-time, and it avoids the need to exert a lot of effort to make a actually-constant-time modular inversion function just for RSA blinding. Note that if the random number generator weren't working correctly then the blinding of the inversion wouldn't be very effective, but in that case the RSA blinding itself would probably be completely busted, so we're not really losing anything by relying on blinding to blind the blinding. Change-Id: I771100f0ad8ed3c24e80dd859ec22463ef2a194f Reviewed-on: https://boringssl-review.googlesource.com/8923 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-29Add a test for BN_cmp_word.David Benjamin
This also adds a missing OPENSSL_EXPORT. Change-Id: I6c2400246280f68f51157e959438644976b1171b Reviewed-on: https://boringssl-review.googlesource.com/9041 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-29Add BN_rand_range_ex and use internally.Brian Smith
There are many cases where we need |BN_rand_range| but with a minimum value other than 0. |BN_rand_range_ex| provides that. Change-Id: I564326c9206bf4e20a37414bdbce16a951c148ce Reviewed-on: https://boringssl-review.googlesource.com/8921 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-29Fix the comments for |SHA[256|384|512]_Transform|.Adam Langley
Change-Id: I6d552d26b3d72f6fffdc4d4d9fc3b5d82fb4e8bb Reviewed-on: https://boringssl-review.googlesource.com/9010 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-28Use Fermat's Little Theorem when converting points to affine.Brian Smith
Fermat's Little Theorem is already used for the custom curve implementations. Use it, for the same reasons, for the ec_montgomery-based implementations. I tested the performance (only) on x86-64 Windows. Change-Id: Ibf770fd3f2d3e2cfe69f06bc12c81171624ff557 Reviewed-on: https://boringssl-review.googlesource.com/8924 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-28Add tests for |BN_mod_inverse| with modulus 1.Brian Smith
Zero is only a valid input to or output of |BN_mod_inverse| when the modulus is one. |BN_MONT_CTX_set| actually depends on this, so test that this works. Change-Id: Ic18f1fe786f668394951d4309020c6ead95e5e28 Reviewed-on: https://boringssl-review.googlesource.com/8922 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-28gofmt crypto/bn/check_bn_tests.go.Brian Smith
Some gerrit git hook says this is necessary. Change-Id: I8a7a0a0e6732688c965b43824fe54b2db79a4919 Reviewed-on: https://boringssl-review.googlesource.com/8990 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-27Avoid one |BN_mod_inverse| in |RSA_check_key|.Brian Smith
|BN_mod_inverse| is expensive and leaky. In this case, we can avoid it completely by taking advantage of the fact that we already have the two values that are supposed to be inverses of each other. Change-Id: I2230b4166fb9d89c7445f9f7c045a4c9e4c377b3 Reviewed-on: https://boringssl-review.googlesource.com/8925 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-27Refactor BN_rand_range to reduce code duplication.Brian Smith
Besides reducing code duplication, also move the relative location of the check of |count|. Previously, the code was generating a random value and then terminating the loop without using it if |count| went to zero. Now the wasted call to |BN_rand| is not made. Also add a note about the applicability of the special case logic for |range| of the form |0b100...| to RSA blinding. Change-Id: Iaa33b9529f1665ac59aefcc8b371fa32445e7578 Reviewed-on: https://boringssl-review.googlesource.com/8960 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-27Remove OPENSSL_ALLOW_PROXY_CERTS.David Benjamin
One less random environment variable for us to be sensitive to. (We should probably unwind all this proxy cert stuff. I don't believe they are ever enabled.) Change-Id: I74993178679ea49e60c81d8416e502cbebf02ec9 Reviewed-on: https://boringssl-review.googlesource.com/8948 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-27Always check that the value returned by asn1_do_adb() is non-NULL.David Benjamin
(Imported from upstream's a9b23465243b6d692bb0b419bdbe0b1f5a849e9c, 5e102f96eb6fcdba1db2dba41132f92fa492aea0, and 9bda72880113b2b2262d290b23bdd1d3b19ff5b3.) Change-Id: Ib608acb86cc128cacf20811c21bf6b38b0520106 Reviewed-on: https://boringssl-review.googlesource.com/8944 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-27Fix ASN1_STRING_to_UTF8 could not convert NumericStringDavid Benjamin
tag2nbyte had -1 at 18th position, but underlying ASN1_mbstring_copy supports NumericString. tag2nbyte is also used in do_print_ex which will not be broken by setting 1 at 18th position of tag2nbyte (Imported from upstream's bd598cc405e981de259a07558e600b5a9ef64bd6.) Change-Id: Ie063afcaac8a7d5046cdb385059b991b92cd6659 Reviewed-on: https://boringssl-review.googlesource.com/8946 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-26Fix omitted selector handling.David Benjamin
The selector field could be omitted because it has a DEFAULT value. In this case *sfld == NULL (sfld can never be NULL). This was not noticed because this was never used in existing ASN.1 modules. (Imported from upstream's c4210673313482edacede58d92e92c213d7a181a.) svaldez and I stared at this for a while and we believe this change is correct. It's also irrelevant because our only remaining ADB (ANY DEFINED BY) table is POLICYQUALINFO which does not allow its selector to be omitted. Also, if it did, it would be a slight change in behavior. We'd switch from using POLICYQUALINFO's default_tt (filling in an ASN1_ANY) to its null_tt (which doesn't exist, so error). Change-Id: If6a929e3dafca18431775b01958d0dae1c09f3b4 Reviewed-on: https://boringssl-review.googlesource.com/8943 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-26Fix an error path leak in int X509_ATTRIBUTE_set1_data()David Benjamin
(Imported from upstream's e6f65f769d87846bdc5b58ef8d2ef4074044022d.) Change-Id: I95df13561481e98faaf8227561228c151dd344b6 Reviewed-on: https://boringssl-review.googlesource.com/8942 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-26Import (unreachable) bsaes-armv7.pl XTS fixes.David Benjamin
This imports upstream's b62e9bf5cbbe278b7e0017c9234999dae68ee867 and c3bc7f498815b355533d96b54b9a09e030d4130c. This is a no-op since we don't use the XTS bits though keep the files in sync so long as we have them. Comparing to master, we're now up-to-date on that file except for a285992763f3961f69a8d86bf7dfff020a08cef9. (I've left that alone since that touches lots of files and we should probably get better test configuration before importing something scary like #undef __thumb2__.) Change-Id: Ie0556757c954ef559e03a6d62c940d5901ca704a Reviewed-on: https://boringssl-review.googlesource.com/8945 Reviewed-by: Adam Langley <agl@google.com>
2016-07-26Fix an error path leak in do_ext_nconf()David Benjamin
(Imported from upstream's 4457017587efae316ac10b159f2e5b0cc81d9921. This also applies the change in https://github.com/openssl/openssl/pull/1351.) Change-Id: Ief4e4b282f5e987981922d127b5345d374d009cf Reviewed-on: https://boringssl-review.googlesource.com/8941 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-26Check for overflow in CBB_add_u24.David Benjamin
All other CBB_add_u<N> functions take a narrowed type, but not every uint32_t may fit in a u24. Check for this rather than silently truncate. Change-Id: I23879ad0f4d2934f257e39e795cf93c6e3e878bf Reviewed-on: https://boringssl-review.googlesource.com/8940 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-25Inline bio_set.David Benjamin
It's only called in one place. The comment about stack-allocated BIOs no longer applies. Change-Id: I5a3cec30bcb46bf1ee2bffd6117485383520b314 Reviewed-on: https://boringssl-review.googlesource.com/8902 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-22Add mod_mul tests where M ≪ A and B.Adam Langley
BN_mod_mul_montgomery has a problem where the modulus is much smaller than one of the arguments. While bn_test.cc knows this and reduces the inputs before testing |BN_mod_mul_montgomery|, none of the previous test vectors actually failed without this. (Except those that passed negative vaules.) This change adds tests where M ≪ A and B. Change-Id: I53b5188ea5fb5e48d0d197718ed33c644cde8477 Reviewed-on: https://boringssl-review.googlesource.com/8890 Reviewed-by: David Benjamin <davidben@google.com> Reviewed-by: Brian Smith <brian@briansmith.org> Commit-Queue: David Benjamin <davidben@google.com>
2016-07-21Drop cached certificate signature validity flagDavid Benjamin
It seems risky in the context of cross-signed certificates when the same certificate might have multiple potential issuers. Also rarely used, since chains in OpenSSL typically only employ self-signed trust-anchors, whose self-signatures are not checked, while untrusted certificates are generally ephemeral. (Imported from upstream's 0e76014e584ba78ef1d6ecb4572391ef61c4fb51.) This is in master and not 1.0.2, but having a per-certificate signature cache when this is a function of signature and issuer seems dubious at best. Thanks to Viktor Dukhovni for pointing this change out to me. (And for making the original change upstream, of course.) Change-Id: Ie692d651726f14aeba6eaab03ac918fcaedb4eeb Reviewed-on: https://boringssl-review.googlesource.com/8880 Reviewed-by: Adam Langley <agl@google.com>
2016-07-20Ensure result affine coordinates in nistz256 are fully reduced.Brian Smith
Revert 3f3358ac150465fafffaf1c51c2928dd2b2018a9. Add documentation clarifying the misunderstanding that lead to the mistake, and make use of the recently-added |bn_set_words|. Change-Id: I58814bace3db3b0b44e2dfe09c44918a4710c621 Reviewed-on: https://boringssl-review.googlesource.com/8831 Reviewed-by: Adam Langley <agl@google.com>
2016-07-19CBBs are in an undefined state after an operation failed.David Benjamin
Our CBB patterns do not make it safe to use a CBB after any operation failed. Suppose one does: int add_to_cbb(CBB *cbb) { CBB child; return CBB_add_u8(cbb, 1) && CBB_add_u8_length_prefixed(cbb, &child) && CBB_add_u8(&child, 2) && /* Flush |cbb| before |child| goes out of scoped. */ CBB_flush(cbb); } If one of the earlier operations fails, any attempt to use |cbb| (except CBB_cleanup) would hit a memory error. Doing this would be a bug anyway, since the CBB would be in an undefined state anyway (wrote only half my object), but the memory error is bad manners. Officially document that using a CBB after failure is illegal and, to avoid the memory error, set a poison bit on the cbb_buffer_st to prevent all future operations. In theory we could make failure + CBB_discard_child work, but this is not very useful and would require a more complex CBB pattern. Change-Id: I4303ee1c326785849ce12b5f7aa8bbde6b95d2ec Reviewed-on: https://boringssl-review.googlesource.com/8840 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-18Switch one point addition to a point doubling in p256-x86_64.c.Brian Smith
Change-Id: I67d8e72ff6f7d0b5d2393555b236510c391f2e78 Reviewed-on: https://boringssl-review.googlesource.com/8830 Reviewed-by: Adam Langley <agl@google.com>
2016-07-18Add TLS 1.3 1-RTT.Steven Valdez
This adds the machinery for doing TLS 1.3 1RTT. Change-Id: I736921ffe9dc6f6e64a08a836df6bb166d20f504 Reviewed-on: https://boringssl-review.googlesource.com/8720 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-16Check for buffered handshake messages on cipher change in DTLS.David Benjamin
This is the equivalent of FragmentAcrossChangeCipherSuite for DTLS. It is possible for us to, while receiving pre-CCS handshake messages, to buffer up a message with sequence number meant for a post-CCS Finished. When we then get to the new epoch and attempt to read the Finished, we will process the buffered Finished although it was sent with the wrong encryption. Move ssl_set_{read,write}_state to SSL_PROTOCOL_METHOD hooks as this is a property of the transport. Notably, read_state may fail. In DTLS check the handshake buffer size. We could place this check in read_change_cipher_spec, but TLS 1.3 has no ChangeCipherSpec message, so we will need to implement this at the cipher change point anyway. (For now, there is only an assert on the TLS side. This will be replaced with a proper check in TLS 1.3.) Change-Id: Ia52b0b81e7db53e9ed2d4f6d334a1cce13e93297 Reviewed-on: https://boringssl-review.googlesource.com/8790 Reviewed-by: Steven Valdez <svaldez@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-16Const-correct HKDF_expand.David Benjamin
prk should be a const parameter. Change-Id: I2369ed9f87fc3c59afc07d3b667b86aec340052e Reviewed-on: https://boringssl-review.googlesource.com/8810 Reviewed-by: Steven Valdez <svaldez@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-07-13RSA_marshal_private_key: add missing CBB_flush()Matt Braithwaite
Change-Id: I2584bd86473be5b9d92a13b65dc78658a433a375 Reviewed-on: https://boringssl-review.googlesource.com/8737 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Implement TLS 1.3's downgrade signal.David Benjamin
For now, skip the 1.2 -> 1.1 signal since that will affect shipping code. We may as well enable it too, but wait until things have settled down. This implements the version in draft-14 since draft-13's isn't backwards-compatible. Change-Id: I46be43e6f4c5203eb4ae006d1c6a2fe7d7a949ec Reviewed-on: https://boringssl-review.googlesource.com/8724 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Change |EVP_PKEY_up_ref| to return int.Adam Langley
Upstream have added |EVP_PKEY_up_ref|, but their version returns an int. Having this function with a different signature like that is dangerous so this change aligns BoringSSL with upstream. Users of this function in Chromium and internally should already have been updated. Change-Id: I0a7aeaf1a1ca3b0f0c635e2ee3826aa100b18157 Reviewed-on: https://boringssl-review.googlesource.com/8736 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Add no-op function ENGINE_register_all_complete.Adam Langley
libssh2 expects this function. Change-Id: Ie2d6ceb25d1b633e1363e82f8a6c187b75a4319f Reviewed-on: https://boringssl-review.googlesource.com/8735 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Refine SHA-1 default in signature algorithm negotiation.David Benjamin
Rather than blindly select SHA-1 if we can't find a matching one, act as if the peer advertised rsa_pkcs1_sha1 and ecdsa_sha1. This means that we will fail the handshake if no common algorithm may be found. This is done in preparation for removing the SHA-1 default in TLS 1.3. Change-Id: I3584947909d3d6988b940f9404044cace265b20d Reviewed-on: https://boringssl-review.googlesource.com/8695 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Revert "Move C++ helpers into |bssl| namespace."Adam Langley
This reverts commit 09feb0f3d95a2bc58ce0faaf14256d3bd30f52a4. (In order to make WebRTC happy this also needs to be reverted.)
2016-07-12Revert scoped_types.h change.Adam Langley
This reverts commits: 8d79ed67407e433d80ebc8d3aa080e8ce16e6eb7 19fdcb523402ed13ab798cf811fb0119e3e7b104 8d79ed67407e433d80ebc8d3aa080e8ce16e6eb7 Because WebRTC (at least) includes our headers in an extern "C" block, which precludes having any C++ in them. Change-Id: Ia849f43795a40034cbd45b22ea680b51aab28b2d
2016-07-12Breaking news: 1998 has come and gone.David Benjamin
Last month's canary for loop did not die in the coal mine of decrepit toolchains. Make a note of this in STYLE.md so we know to start breeding more of them. We can indeed declare index variables like it's 1999. I haven't bothered to convert all of our for loops because that will be tedious, but we can do it as we touch the code. Or if someone feels really really bored. BUG=47 Change-Id: Ib76c0767c1b509e825eac66f8c2e3ee2134e2493 Reviewed-on: https://boringssl-review.googlesource.com/8740 Reviewed-by: Adam Langley <agl@google.com>
2016-07-12Remove scoped_types.h.Adam Langley
This change scatters the contents of the two scoped_types.h files into the headers for each of the areas of the code. The types are now in the |bssl| namespace. Change-Id: I802b8de68fba4786b6a0ac1bacd11d81d5842423 Reviewed-on: https://boringssl-review.googlesource.com/8731 Reviewed-by: Adam Langley <agl@google.com>
2016-07-12Move C++ helpers into |bssl| namespace.Adam Langley
We currently have the situation where the |tool| and |bssl_shim| code includes scoped_types.h from crypto/test and ssl/test. That's weird and shouldn't happen. Also, our C++ consumers might quite like to have access to the scoped types. Thus this change moves some of the template code to base.h and puts it all in a |bssl| namespace to prepare for scattering these types into their respective headers. In order that all the existing test code be able to access these types, it's all moved into the same namespace. Change-Id: I3207e29474dc5fcc344ace43119df26dae04eabb Reviewed-on: https://boringssl-review.googlesource.com/8730 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Reorder functions in bn_test.David Benjamin
We usually put main at the end. There's now nothing interesting in the function, so avoid having to declare every test at the top. Change-Id: Iac469f41f0fb7d1f58d12dfbf651bf0d39f073d0 Reviewed-on: https://boringssl-review.googlesource.com/8712 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-12Convert BN_mod_sqrt tests to bn_tests.txt.David Benjamin
That removes the last of the bc stuff. BUG=31 Change-Id: If64c974b75c36daf14c46f07b0d9355b7cd0adcb Reviewed-on: https://boringssl-review.googlesource.com/8711 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-11Define RAND_cleanup in one place onlyAlessandro Ghedini
Change-Id: I439e275394c2ad686924f4e7dfc99cfdc7bb14b9 Reviewed-on: https://boringssl-review.googlesource.com/8682 Reviewed-by: Adam Langley <agl@google.com>
2016-07-07Document that BN_mod_sqrt assumes p is a prime.David Benjamin
Change-Id: I5be2337ce6c333b704894c64e7931919bc047995 Reviewed-on: https://boringssl-review.googlesource.com/8595 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Convert test_exp to bn_tests.txt.David Benjamin
Amazingly, this function actually has (not crypto-related) callers, despite being pretty much useless for cryptography. BUG=31 Change-Id: I440827380995695c7a15bbf2220a05ffb28d9335 Reviewed-on: https://boringssl-review.googlesource.com/8594 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Convert test_mod_exp_mont5 test vectors.David Benjamin
These were generated by running test_mod_exp_mont5 10 times. The values with Montgomery representation 1 were generated separately so the test file could preserve the comment. (Though, at 10,000 lines, no one's going to find it...) BUG=31 Change-Id: I8e9d4d6d7b5f7d283bd259df10a1dbdc90b888cf Reviewed-on: https://boringssl-review.googlesource.com/8611 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Convert test_mod_exp and test_mod_exp_consttime.David Benjamin
Honestly, with this size of number, they're pretty bad test vectors. test_mod_exp_mont5 will be imported in the next commit which should help. This was done by taking test_mod_exp's generation, running it a few times (since otherwise the modulus is always the same). I also ran it a few times with the odd constraint removed since BN_mod_exp is supposed to support it, even if it's not actually useful. BUG=31 Change-Id: Id53953f0544123a5ea71efac534946055dd5aabc Reviewed-on: https://boringssl-review.googlesource.com/8610 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Fold the rest of test_sqrt into TestSquare.David Benjamin
BUG=31 Change-Id: Ief7bda365c3d786f946caaba0ab2af03c50459c3 Reviewed-on: https://boringssl-review.googlesource.com/8609 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Convert test_mont and test_mod_mul to bn_tests.txt.David Benjamin
That one needs reduced inputs and the other ought to be also tested against unreduced ones is a bit annoying. But the previous commit made sure BN_nnmod has tests, and test_mont could stand to inherit test_mod_mul's test data (it only had five tests originally!), so I merged them. BUG=31 Change-Id: I1eb585b14f85f0ea01ee81537a01e07ced9f5d9a Reviewed-on: https://boringssl-review.googlesource.com/8608 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Add tests for BN_nnmod.David Benjamin
Change-Id: Ic72e00bb01d254408671b3f8d036be3cd4c06086 Reviewed-on: https://boringssl-review.googlesource.com/8606 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Generate more test data in test_mont.David Benjamin
In preparation for converting test_mont and test_mod_mul to test vectors, make test_mont less silly. We can certainly get away with doing more than five tests. Also generate |a| and |b| anew each time. Otherwise the first BN_nmod is destructive. Change-Id: I944007ed7b6013a16d972cb7290ab9992c9360ce Reviewed-on: https://boringssl-review.googlesource.com/8605 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Use BN_set_bit in TestLShift1.David Benjamin
No need for the special case and such. Change-Id: If8fbc73eda0ccbaf3fd422e97c96fee6dc10b1ab Reviewed-on: https://boringssl-review.googlesource.com/8604 Reviewed-by: David Benjamin <davidben@google.com>
2016-07-07Add a Go tool to check bn_tests.txt.David Benjamin
Since the format no longer is readable by bc, compare it to Go's math/big instead. Change-Id: I34d37aa0c29c6f4178267858cb0d3941b4266b93 Reviewed-on: https://boringssl-review.googlesource.com/8603 Reviewed-by: David Benjamin <davidben@google.com>