blob: 9730b47cef315e3f5e3e2e18926178b7c57406a4 [file] [log] [blame]
Damien Miller60ccbf22009-03-06 01:03:30 +11001/* $OpenBSD: schnorr.h,v 1.1 2009/03/05 07:18:19 djm Exp $ */
2/*
3 * Copyright (c) 2009 Damien Miller. All rights reserved.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef SCHNORR_H
19#define SCHNORR_H
20
21#include <sys/types.h>
22
23#include <openssl/bn.h>
24
25struct modp_group {
26 BIGNUM *p, *q, *g;
27};
28
29BIGNUM *bn_rand_range_gt_one(const BIGNUM *high);
30int hash_buffer(const u_char *, u_int, const EVP_MD *, u_char **, u_int *);
31void debug3_bn(const BIGNUM *, const char *, ...)
32 __attribute__((__nonnull__ (2)))
33 __attribute__((format(printf, 2, 3)));
34void debug3_buf(const u_char *, u_int, const char *, ...)
35 __attribute__((__nonnull__ (3)))
36 __attribute__((format(printf, 3, 4)));
37struct modp_group *modp_group_from_g_and_safe_p(const char *, const char *);
38void modp_group_free(struct modp_group *);
39
40/* Signature and verification functions */
41int
42schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
43 const EVP_MD *evp_md, const BIGNUM *x, const BIGNUM *g_x,
44 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p);
45int
46schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
47 const BIGNUM *x, const BIGNUM *g_x, const u_char *id, u_int idlen,
48 u_char **sig, u_int *siglen);
49int
50schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
51 const EVP_MD *evp_md, const BIGNUM *g_x, const u_char *id, u_int idlen,
52 const BIGNUM *r, const BIGNUM *e);
53int
54schnorr_verify_buf(const BIGNUM *grp_p, const BIGNUM *grp_q,
55 const BIGNUM *grp_g,
56 const BIGNUM *g_x, const u_char *id, u_int idlen,
57 const u_char *sig, u_int siglen);
58
59#endif /* JPAKE_H */
60