diff options
author | Niels Möller <nisse@lysator.liu.se> | 2012-06-09 21:55:50 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2012-06-09 21:55:50 +0200 |
commit | 527c0f3708a5f3a098aedda58afdc287a7f8e97c (patch) | |
tree | f191cf1789f49b1da04a439c6b56035eb9553b00 /pkcs1-rsa-digest.c | |
parent | a3eb7a92ee86bb01ebe1a52de88244a9c0c39ca8 (diff) | |
download | nettle-527c0f3708a5f3a098aedda58afdc287a7f8e97c.tar.gz |
General pkcs1 signature interface.
Diffstat (limited to 'pkcs1-rsa-digest.c')
-rw-r--r-- | pkcs1-rsa-digest.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pkcs1-rsa-digest.c b/pkcs1-rsa-digest.c new file mode 100644 index 00000000..e84db6d4 --- /dev/null +++ b/pkcs1-rsa-digest.c @@ -0,0 +1,49 @@ +/* pkcs1-rsa-digest.c + * + */ + +/* nettle, low-level cryptographics library + * + * Copyright (C) 2001, 2003, 2012 Niels Möller + * + * The nettle library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * The nettle library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the nettle library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "pkcs1.h" + +#include "bignum.h" +#include "nettle-internal.h" + +int +pkcs1_rsa_digest_encode(mpz_t m, unsigned key_size, + unsigned di_length, const uint8_t *digest_info) +{ + TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE); + TMP_ALLOC(em, key_size); + + if (pkcs1_signature_prefix(key_size, em, + di_length, digest_info, 0)) + { + nettle_mpz_set_str_256_u(m, key_size, em); + return 1; + } + else + return 0; +} |