Change compiler flag definition place to fix ASAN build break on ARM
[platform/upstream/nettle.git] / pkcs1-rsa-digest.c
1 /* pkcs1-rsa-digest.c
2  *
3  */
4
5 /* nettle, low-level cryptographics library
6  *
7  * Copyright (C) 2001, 2003, 2012 Niels Möller
8  *  
9  * The nettle library is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or (at your
12  * option) any later version.
13  * 
14  * The nettle library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17  * License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the nettle library; see the file COPYING.LIB.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02111-1301, USA.
23  */
24
25 #if HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include "pkcs1.h"
30
31 #include "bignum.h"
32 #include "nettle-internal.h"
33
34 int
35 pkcs1_rsa_digest_encode(mpz_t m, unsigned key_size,
36                         unsigned di_length, const uint8_t *digest_info)
37 {
38   TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
39   TMP_ALLOC(em, key_size);
40
41   if (_pkcs1_signature_prefix(key_size, em,
42                               di_length, digest_info, 0))
43     {
44       nettle_mpz_set_str_256_u(m, key_size, em);
45       return 1;
46     }
47   else
48     return 0;
49 }