diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-09-26 11:04:55 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-30 05:42:15 +0000 |
commit | 400851595a7a3961adac0bc9e6aba8eb323159bb (patch) | |
tree | fcc5c114e48117ed627a381b724fa7cdec0755b6 /include/rsa.h | |
parent | b67eadf7029198224cd59abb85b210fdd326e268 (diff) | |
download | chrome-ec-400851595a7a3961adac0bc9e6aba8eb323159bb.tar.gz |
add RSA signature verification code
2048-bit RSA public key cryptography signature verification code
which uses a pre-processed key for computation.
it is based on the code from vboot :
platform/vboot_reference/firmware/2lib/2rsa.c
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=samus
BUG=chrome-os-partner:28336
TEST=using following CL, on Zinger, verify RW firmware signature.
Change-Id: I681a29144eb805cd5758aa6efe697ce2f656a298
Reviewed-on: https://chromium-review.googlesource.com/220186
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/rsa.h')
-rw-r--r-- | include/rsa.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/rsa.h b/include/rsa.h new file mode 100644 index 0000000000..95e17450c6 --- /dev/null +++ b/include/rsa.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2014 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. + */ + +#ifndef _INCLUDE_RSA_H +#define _INCLUDE_RSA_H + +#include "common.h" + +#define RSANUMBYTES 256 /* 2048 bit key length */ +#define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t)) + +/* 2048-bit RSA public key definition */ +struct rsa_public_key { + uint32_t n[RSANUMWORDS]; /* modulus as little endian array */ + uint32_t rr[RSANUMWORDS]; /* R^2 as little endian array */ + uint32_t n0inv; /* -1 / n[0] mod 2^32 */ +}; + +int rsa_verify(const struct rsa_public_key *key, + const uint8_t *signature, + const uint8_t *sha, + uint32_t *workbuf32); + +#endif /* _INCLUDE_RSA_H */ |