X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=dsa%2Fdsa.h;fp=dsa%2Fdsa.h;h=ab744b2e0ded28db1f4c90bbcff7d20cfbfbe8cf;hp=0000000000000000000000000000000000000000;hb=2a4779378a7bf4322a0e6b2024284092135e8a3d;hpb=e69f1207a9fbd9c0f45bfdbb2d8ebe9852d95969 diff --git a/dsa/dsa.h b/dsa/dsa.h new file mode 100644 index 0000000..ab744b2 --- /dev/null +++ b/dsa/dsa.h @@ -0,0 +1,59 @@ +/* dsa.h */ +/* + This file is part of the ARM-Crypto-Lib. + Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef DSA_H_ +#define DSA_H_ + +#include +#include "hfal-basic.h" +#include "bigint.h" + +typedef struct{ + bigint_t p; + bigint_t q; + bigint_t g; +} dsa_domainparameters_t; + +typedef bigint_t dsa_pubkey_t; +typedef bigint_t dsa_privkey_t; +typedef struct{ + bigint_t r; + bigint_t s; +} dsa_signature_t; + +typedef struct{ + dsa_privkey_t priv; + dsa_pubkey_t pub; + dsa_domainparameters_t domain; +} dsa_ctx_t; + +#define DSA_SIGNATURE_OK 1 +#define DSA_SIGNATURE_FAIL 0 + +uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m, + const dsa_ctx_t* ctx, const bigint_t* k); +uint8_t dsa_sign_message(dsa_signature_t* s, const void* m, uint16_t m_len_b, + const hfdesc_t* hash_desc, const dsa_ctx_t* ctx, + uint8_t(*rand_in)(void)); +uint8_t dsa_verify_bigint(const dsa_signature_t* s, const bigint_t* m, + const dsa_ctx_t* ctx); +uint8_t dsa_verify_message(const dsa_signature_t* s, const void* m, uint16_t m_len_b, + const hfdesc_t* hash_desc, const dsa_ctx_t* ctx); + +#endif /* DSA_H_ */