Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 1 | /* |
Sridhar Parasuram | b27e47c | 2015-05-27 14:33:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2011,2014-2015 The Linux Foundation. All rights reserved. |
Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in |
| 11 | * the documentation and/or other materials provided with the |
| 12 | * distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 17 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 18 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 20 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 21 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 22 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 24 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 25 | * SUCH DAMAGE. |
| 26 | */ |
| 27 | #ifndef __IMAGE_VERIFY_H |
| 28 | #define __IMAGE_VERIFY_H |
| 29 | |
Shashank Mittal | 64d0485 | 2014-08-28 15:02:46 -0700 | [diff] [blame] | 30 | #include <x509.h> |
| 31 | |
Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 32 | #define SHA1_SIZE 16 |
| 33 | #define SHA256_SIZE 32 |
| 34 | /* For keys of length 2048 bits */ |
| 35 | #define SIGNATURE_SIZE 256 |
| 36 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 37 | static int image_decrypt_signature(unsigned char *signature_ptr, |
| 38 | unsigned char *plain_text); |
| 39 | int image_verify(unsigned char *image_ptr, |
| 40 | unsigned char *signature_ptr, |
| 41 | unsigned int image_size, unsigned hash_type); |
Shashank Mittal | 64d0485 | 2014-08-28 15:02:46 -0700 | [diff] [blame] | 42 | |
| 43 | /* Decrypt signature with RSA public key */ |
| 44 | int image_decrypt_signature_rsa(unsigned char *signature_ptr, |
| 45 | unsigned char *plain_text, RSA *rsa_key); |
| 46 | |
| 47 | /* Find hash of image */ |
| 48 | void image_find_digest(unsigned char *image_ptr, unsigned int image_size, |
| 49 | unsigned hash_type, unsigned char *digest); |
vijay kumar | 4f4405f | 2014-08-08 11:49:53 +0530 | [diff] [blame] | 50 | void save_kernel_hash_cmd(void *digest); |
Sridhar Parasuram | b27e47c | 2015-05-27 14:33:54 -0700 | [diff] [blame] | 51 | void save_kernel_hash(unsigned char *digest, unsigned hash_type); |
Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 52 | #endif |