112 lines
6.0 KiB
C
112 lines
6.0 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.
|
|
*
|
|
* RSA 2048 with 3 exponent public key and verification.
|
|
* Private key in rsa2048-3.pem.
|
|
*/
|
|
|
|
/* First generate a key:
|
|
* # openssl genrsa -3 -out key.pem 2048
|
|
* # openssl rsa -in key.pem -pubout > key.pub
|
|
* Then dump the key:
|
|
* # dumpRSAPublicKey -pub key.pub | xxd -i
|
|
*/
|
|
const uint8_t rsa_data[] = {
|
|
0x40, 0x00, 0x00, 0x00, 0x0f, 0x46, 0xe8, 0x2c, 0x11, 0x17, 0x38, 0xfd,
|
|
0xef, 0xa2, 0xb5, 0x2d, 0x6d, 0x76, 0xe1, 0x70, 0x7d, 0x67, 0xb1, 0x9a,
|
|
0x18, 0x78, 0x90, 0xe2, 0xce, 0xa6, 0x81, 0xa0, 0x13, 0x37, 0xf2, 0x71,
|
|
0xf0, 0x44, 0x96, 0xaf, 0x52, 0x53, 0xd4, 0x23, 0x51, 0x19, 0xe5, 0xb0,
|
|
0x6d, 0x95, 0x99, 0x11, 0x88, 0x5c, 0xed, 0x52, 0x62, 0x07, 0xa6, 0x02,
|
|
0xc6, 0xba, 0x48, 0xae, 0x78, 0xd9, 0xfb, 0x73, 0x7a, 0x33, 0xfe, 0x8b,
|
|
0xe5, 0x38, 0xf6, 0x8b, 0xa1, 0x3f, 0x1d, 0xe1, 0xfc, 0xae, 0x19, 0xf1,
|
|
0x80, 0x94, 0x06, 0xfc, 0x44, 0x69, 0x3c, 0xec, 0xb2, 0xf0, 0x29, 0x9a,
|
|
0x97, 0x09, 0x81, 0x88, 0x1a, 0x56, 0x2e, 0xcb, 0xf9, 0x0b, 0x08, 0x5c,
|
|
0xd3, 0x44, 0x6a, 0xce, 0xe2, 0xbc, 0x71, 0x03, 0x93, 0x0b, 0x80, 0x0e,
|
|
0x12, 0x4c, 0x25, 0x61, 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, 0x43, 0x9b, 0xdf, 0x26, 0xeb, 0x2e,
|
|
0x80, 0xe2, 0x27, 0x9e, 0xd3, 0xa5, 0x45, 0x37, 0x4c, 0xbd, 0xf9, 0xb0,
|
|
0x23, 0xa1, 0x21, 0x4e, 0x1f, 0x6e, 0xdd, 0xac, 0xa6, 0x2c, 0x83, 0x61,
|
|
0xdf, 0x8f, 0x9a, 0xfb, 0x55, 0x0a, 0x88, 0x0b, 0x0b, 0x34, 0xbd, 0x35,
|
|
0x43, 0x2d, 0xe4, 0x49,
|
|
};
|
|
|
|
const struct rsa_public_key *rsa_key = (struct rsa_public_key *)rsa_data;
|
|
BUILD_ASSERT(sizeof(*rsa_key) == sizeof(rsa_data));
|
|
|
|
/* SHA-256 sum to verify:
|
|
* # sha256sum README | sed -e 's/\(..\)/0x\1, /mg'
|
|
*/
|
|
const uint8_t hash[] = {
|
|
0x6c, 0x5f, 0xef, 0x7f, 0x63, 0x1d, 0xb4, 0x35, 0x6c, 0xae, 0x8b, 0x2a,
|
|
0x4e, 0xde, 0xc5, 0xeb, 0x11, 0xba, 0x1f, 0x44, 0x40, 0xb6, 0x3a, 0x52,
|
|
0xf2, 0x70, 0xef, 0xee, 0x44, 0x4b, 0x57, 0x62
|
|
};
|
|
|
|
/* Incorrect hash to test the negative case */
|
|
const uint8_t hash_wrong[] = {
|
|
0x61, 0x1b, 0xd2, 0x44, 0xc7, 0x18, 0xa7, 0x2d, 0x0f, 0x2d, 0x3d, 0x0f,
|
|
0xe3, 0xb3, 0xc5, 0xe4, 0x12, 0xc2, 0x7b, 0x1e, 0x05, 0x2c, 0x6f, 0xad,
|
|
0xc4, 0xac, 0x71, 0x55, 0xe8, 0x80, 0x5c, 0x38
|
|
};
|
|
|
|
/* Generate signature using futility:
|
|
* # futility create key.pem
|
|
* # futility sign --type rwsig --prikey key.vbprik2 README README.out
|
|
* # dd skip=56 bs=1 if=README.out | xxd -i
|
|
*/
|
|
const uint8_t sig[] = {
|
|
0xad, 0x93, 0x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