1/* $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#ifdef __APPLE_CRYPTO__ 24#include "ossl-bn.h" 25#else 26#include <openssl/bn.h> 27#endif 28 29struct modp_group { 30 BIGNUM *p, *q, *g; 31}; 32 33BIGNUM *bn_rand_range_gt_one(const BIGNUM *high); 34int hash_buffer(const u_char *, u_int, const EVP_MD *, u_char **, u_int *); 35void debug3_bn(const BIGNUM *, const char *, ...) 36 __attribute__((__nonnull__ (2))) 37 __attribute__((format(printf, 2, 3))); 38void debug3_buf(const u_char *, u_int, const char *, ...) 39 __attribute__((__nonnull__ (3))) 40 __attribute__((format(printf, 3, 4))); 41struct modp_group *modp_group_from_g_and_safe_p(const char *, const char *); 42void modp_group_free(struct modp_group *); 43 44/* Signature and verification functions */ 45int 46schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 47 const EVP_MD *evp_md, const BIGNUM *x, const BIGNUM *g_x, 48 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p); 49int 50schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 51 const BIGNUM *x, const BIGNUM *g_x, const u_char *id, u_int idlen, 52 u_char **sig, u_int *siglen); 53int 54schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 55 const EVP_MD *evp_md, const BIGNUM *g_x, const u_char *id, u_int idlen, 56 const BIGNUM *r, const BIGNUM *e); 57int 58schnorr_verify_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, 59 const BIGNUM *grp_g, 60 const BIGNUM *g_x, const u_char *id, u_int idlen, 61 const u_char *sig, u_int siglen); 62 63#endif /* JPAKE_H */ 64 65