mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
This tests RSA 2048 with public exponent 3. BRANCH=none BUG=chromium:663631 TEST=make run-rsa3 Change-Id: I979ad4a23de6baba63aba037d2713b74fed4737f Reviewed-on: https://chromium-review.googlesource.com/408130 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/* Copyright 2016 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*
|
|
* Tests RSA implementation.
|
|
*/
|
|
|
|
#include "console.h"
|
|
#include "common.h"
|
|
#include "rsa.h"
|
|
#include "test_util.h"
|
|
#include "util.h"
|
|
|
|
#ifdef TEST_RSA3
|
|
#include "rsa2048-3.h"
|
|
#else
|
|
#include "rsa2048-F4.h"
|
|
#endif
|
|
|
|
void run_test(void)
|
|
{
|
|
int good;
|
|
uint32_t rsa_workbuf[3 * RSANUMBYTES/4];
|
|
|
|
good = rsa_verify(rsa_key, sig, hash, rsa_workbuf);
|
|
if (!good) {
|
|
ccprintf("RSA verify FAILED\n");
|
|
test_fail();
|
|
return;
|
|
}
|
|
ccprintf("RSA verify OK\n");
|
|
|
|
/* Test with a wrong hash */
|
|
good = rsa_verify(rsa_key, sig, hash_wrong, rsa_workbuf);
|
|
if (good) {
|
|
ccprintf("RSA verify OK (expected fail)\n");
|
|
test_fail();
|
|
return;
|
|
}
|
|
ccprintf("RSA verify FAILED (as expected)\n");
|
|
|
|
/* Test with a wrong signature */
|
|
good = rsa_verify(rsa_key, sig+1, hash, rsa_workbuf);
|
|
if (good) {
|
|
ccprintf("RSA verify OK (expected fail)\n");
|
|
test_fail();
|
|
return;
|
|
}
|
|
ccprintf("RSA verify FAILED (as expected)\n");
|
|
|
|
test_pass();
|
|
}
|
|
|