| 1 | /* |
| 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | * |
| 16 | * See file CREDITS for list of people who contributed to this |
| 17 | * project. |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * crypto.h - Definitions for the crypto support. |
| 22 | */ |
| 23 | |
| 24 | #ifndef INCLUDED_CRYPTO_H_N |
| 25 | #define INCLUDED_CRYPTO_H_N |
| 26 | |
| 27 | #include "cbootimage.h" |
| 28 | |
| 29 | /* lengths, in bytes */ |
| 30 | #define KEY_LENGTH (128/8) |
| 31 | |
| 32 | #define ICEIL(a, b) (((a) + (b) - 1)/(b)) |
| 33 | |
| 34 | #define AES_CMAC_CONST_RB 0x87 // from RFC 4493, Figure 2.2 |
| 35 | |
| 36 | /* Function prototypes */ |
| 37 | |
| 38 | int |
| 39 | sign_bct(build_image_context *context, |
| 40 | uint8_t *bct); |
| 41 | |
| 42 | int |
| 43 | sign_data_block(uint8_t *source, |
| 44 | uint32_t length, |
| 45 | uint8_t *signature); |
| 46 | |
| 47 | void |
| 48 | reverse_byte_order( |
| 49 | uint8_t *out, |
| 50 | const uint8_t *in, |
| 51 | const uint32_t size); |
| 52 | |
| 53 | int |
| 54 | sign_bl(build_image_context *context, |
| 55 | uint8_t *bootloader, |
| 56 | uint32_t length, |
| 57 | uint32_t image_instance); |
| 58 | |
| 59 | #endif /* #ifndef INCLUDED_CRYPTO_H */ |