Files
OpenCellular/include/rsa.h
Vincent Palatin 400851595a 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>
2014-09-30 05:42:15 +00:00

27 lines
765 B
C

/* 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 */