| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_TEST_WYCHEPROOF_UTIL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_TEST_WYCHEPROOF_UTIL_H |
| 17 |
| 18 | #include <openssl/base.h> |
| 19 |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 |
| 23 |
| 24 | // This header contains convenience functions for Wycheproof tests. |
| 25 |
| 26 | class FileTest; |
| 27 |
| 28 | enum class WycheproofRawResult { |
| 29 | kValid, |
| 30 | kInvalid, |
| 31 | kAcceptable, |
| 32 | }; |
| 33 |
| 34 | struct WycheproofResult { |
| 35 | WycheproofRawResult raw_result; |
| 36 | std::vector<std::string> flags; |
| 37 |
| 38 | // IsValid returns true if the Wycheproof test should be considered valid. A |
| 39 | // test result of "acceptable" is treated as valid if all flags are included |
| 40 | // in |acceptable_flags| and invalid otherwise. |
| 41 | bool IsValid(const std::vector<std::string> &acceptable_flags = {}) const; |
| 42 | }; |
| 43 |
| 44 | // GetWycheproofResult sets |*out| to the parsed "result" and "flags" keys of |t|. |
| 45 | bool GetWycheproofResult(FileTest *t, WycheproofResult *out); |
| 46 |
| 47 | // GetWycheproofDigest returns a digest function using the Wycheproof name, or |
| 48 | // nullptr on error. |
| 49 | const EVP_MD *GetWycheproofDigest(FileTest *t, const char *key, |
| 50 | bool instruction); |
| 51 |
| 52 | // GetWycheproofCurve returns a curve using the Wycheproof name, or nullptr on |
| 53 | // error. |
| 54 | const EC_GROUP *GetWycheproofCurve(FileTest *t, const char *key, |
| 55 | bool instruction); |
| 56 |
| 57 | // GetWycheproofBIGNUM returns a BIGNUM in the Wycheproof format, or nullptr on |
| 58 | // error. |
| 59 | bssl::UniquePtr<BIGNUM> GetWycheproofBIGNUM(FileTest *t, const char *key, |
| 60 | bool instruction); |
| 61 |
| 62 |
| 63 | #endif // OPENSSL_HEADER_CRYPTO_TEST_WYCHEPROOF_UTIL_H |
| 64 |