15b69db07SJason Zhu /* 25b69db07SJason Zhu * Copyright (C) 2016 The Android Open Source Project 35b69db07SJason Zhu * 45b69db07SJason Zhu * Permission is hereby granted, free of charge, to any person 55b69db07SJason Zhu * obtaining a copy of this software and associated documentation 65b69db07SJason Zhu * files (the "Software"), to deal in the Software without 75b69db07SJason Zhu * restriction, including without limitation the rights to use, copy, 85b69db07SJason Zhu * modify, merge, publish, distribute, sublicense, and/or sell copies 95b69db07SJason Zhu * of the Software, and to permit persons to whom the Software is 105b69db07SJason Zhu * furnished to do so, subject to the following conditions: 115b69db07SJason Zhu * 125b69db07SJason Zhu * The above copyright notice and this permission notice shall be 135b69db07SJason Zhu * included in all copies or substantial portions of the Software. 145b69db07SJason Zhu * 155b69db07SJason Zhu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 165b69db07SJason Zhu * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 175b69db07SJason Zhu * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 185b69db07SJason Zhu * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 195b69db07SJason Zhu * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 205b69db07SJason Zhu * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 215b69db07SJason Zhu * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 225b69db07SJason Zhu * SOFTWARE. 235b69db07SJason Zhu */ 245b69db07SJason Zhu 255b69db07SJason Zhu /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 265b69db07SJason Zhu * Use of this source code is governed by a BSD-style license that can be 275b69db07SJason Zhu * found in the LICENSE file. 285b69db07SJason Zhu */ 295b69db07SJason Zhu 30*37a7bc39SJason Zhu /* 315b69db07SJason Zhu #ifdef AVB_INSIDE_LIBAVB_H 325b69db07SJason Zhu #error "You can't include avb_rsa.h in the public header libavb.h." 335b69db07SJason Zhu #endif 34*37a7bc39SJason Zhu */ 355b69db07SJason Zhu 365b69db07SJason Zhu /* 375b69db07SJason Zhu #ifndef AVB_COMPILATION 385b69db07SJason Zhu #error "Never include this file, it may only be used from internal avb code." 395b69db07SJason Zhu #endif 405b69db07SJason Zhu */ 415b69db07SJason Zhu 425b69db07SJason Zhu #ifndef AVB_RSA_H_ 435b69db07SJason Zhu #define AVB_RSA_H_ 445b69db07SJason Zhu 455b69db07SJason Zhu #ifdef __cplusplus 465b69db07SJason Zhu extern "C" { 475b69db07SJason Zhu #endif 485b69db07SJason Zhu 495b69db07SJason Zhu #include <android_avb/avb_crypto.h> 505b69db07SJason Zhu #include <android_avb/avb_sysdeps.h> 515b69db07SJason Zhu 525b69db07SJason Zhu /* Using the key given by |key|, verify a RSA signature |sig| of 535b69db07SJason Zhu * length |sig_num_bytes| against an expected |hash| of length 545b69db07SJason Zhu * |hash_num_bytes|. The padding to expect must be passed in using 555b69db07SJason Zhu * |padding| of length |padding_num_bytes|. 565b69db07SJason Zhu * 575b69db07SJason Zhu * The data in |key| must match the format defined in 585b69db07SJason Zhu * |AvbRSAPublicKeyHeader|, including the two large numbers 595b69db07SJason Zhu * following. The |key_num_bytes| must be the size of the entire 605b69db07SJason Zhu * serialized key. 615b69db07SJason Zhu * 625b69db07SJason Zhu * Returns false if verification fails, true otherwise. 635b69db07SJason Zhu */ 645b69db07SJason Zhu bool avb_rsa_verify(const uint8_t* key, 655b69db07SJason Zhu size_t key_num_bytes, 665b69db07SJason Zhu const uint8_t* sig, 675b69db07SJason Zhu size_t sig_num_bytes, 685b69db07SJason Zhu const uint8_t* hash, 695b69db07SJason Zhu size_t hash_num_bytes, 705b69db07SJason Zhu const uint8_t* padding, 715b69db07SJason Zhu size_t padding_num_bytes) AVB_ATTR_WARN_UNUSED_RESULT; 725b69db07SJason Zhu 735b69db07SJason Zhu #ifdef __cplusplus 745b69db07SJason Zhu } 755b69db07SJason Zhu #endif 765b69db07SJason Zhu 775b69db07SJason Zhu #endif /* AVB_RSA_H_ */ 78