1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
// -*-c++-*-
/* $Id: dsa.h,v 1.2 2006/02/26 02:21:16 kaminsky Exp $ */
/*
*
* Copyright (C) 2006 Michael Kaminsky (kaminsky at csail.mit.edu)
*
* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
#ifndef _DSA_H_
#define _DSA_H_ 1
#include "fips186.h"
struct dsa_pub {
const bigint p;
const bigint q;
const bigint g;
const bigint y;
dsa_pub (const bigint &pp, const bigint &qq,
const bigint &gg, const bigint &yy)
: p (pp), q (qq), g (gg), y (yy) {}
virtual ~dsa_pub () {}
bool verify (const str &msg, const bigint &r, const bigint &s);
protected:
bigint msghash_to_bigint (const str &msg);
};
struct dsa_priv : public dsa_pub {
const bigint x;
dsa_priv (const bigint &pp, const bigint &qq, const bigint &gg,
const bigint &yy, const bigint &xx)
: dsa_pub (pp, qq, gg, yy), x (xx) {}
void sign (bigint *r, bigint *s, const str &msg);
};
struct dsa_gen : public fips186_gen {
ptr<dsa_priv> sk;
dsa_gen (u_int pbits, u_int iter) : fips186_gen (pbits, iter) {}
static ptr<dsa_gen> rgen (u_int pbits, u_int iter = 32) {
ref<dsa_gen> dg = New refcounted<dsa_gen> (pbits, iter);
dg->gen (iter);
return dg;
}
private:
void gen (u_int iter);
};
#endif /* !_DSA_H_ */
|