ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:1387ff3eed4a 1 /* dsa.h
sPymbed 0:1387ff3eed4a 2 *
sPymbed 0:1387ff3eed4a 3 * Copyright (C) 2006-2017 wolfSSL Inc.
sPymbed 0:1387ff3eed4a 4 *
sPymbed 0:1387ff3eed4a 5 * This file is part of wolfSSL.
sPymbed 0:1387ff3eed4a 6 *
sPymbed 0:1387ff3eed4a 7 * wolfSSL is free software; you can redistribute it and/or modify
sPymbed 0:1387ff3eed4a 8 * it under the terms of the GNU General Public License as published by
sPymbed 0:1387ff3eed4a 9 * the Free Software Foundation; either version 2 of the License, or
sPymbed 0:1387ff3eed4a 10 * (at your option) any later version.
sPymbed 0:1387ff3eed4a 11 *
sPymbed 0:1387ff3eed4a 12 * wolfSSL is distributed in the hope that it will be useful,
sPymbed 0:1387ff3eed4a 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
sPymbed 0:1387ff3eed4a 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sPymbed 0:1387ff3eed4a 15 * GNU General Public License for more details.
sPymbed 0:1387ff3eed4a 16 *
sPymbed 0:1387ff3eed4a 17 * You should have received a copy of the GNU General Public License
sPymbed 0:1387ff3eed4a 18 * along with this program; if not, write to the Free Software
sPymbed 0:1387ff3eed4a 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
sPymbed 0:1387ff3eed4a 20 */
sPymbed 0:1387ff3eed4a 21
sPymbed 0:1387ff3eed4a 22 /*!
sPymbed 0:1387ff3eed4a 23 \file wolfssl/wolfcrypt/dsa.h
sPymbed 0:1387ff3eed4a 24 */
sPymbed 0:1387ff3eed4a 25
sPymbed 0:1387ff3eed4a 26 #ifndef WOLF_CRYPT_DSA_H
sPymbed 0:1387ff3eed4a 27 #define WOLF_CRYPT_DSA_H
sPymbed 0:1387ff3eed4a 28
sPymbed 0:1387ff3eed4a 29 #include <wolfcrypt/types.h>
sPymbed 0:1387ff3eed4a 30
sPymbed 0:1387ff3eed4a 31 #ifndef NO_DSA
sPymbed 0:1387ff3eed4a 32
sPymbed 0:1387ff3eed4a 33 #include <wolfcrypt/integer.h>
sPymbed 0:1387ff3eed4a 34 #include <wolfcrypt/random.h>
sPymbed 0:1387ff3eed4a 35
sPymbed 0:1387ff3eed4a 36 /* for DSA reverse compatibility */
sPymbed 0:1387ff3eed4a 37 #define InitDsaKey wc_InitDsaKey
sPymbed 0:1387ff3eed4a 38 #define FreeDsaKey wc_FreeDsaKey
sPymbed 0:1387ff3eed4a 39 #define DsaSign wc_DsaSign
sPymbed 0:1387ff3eed4a 40 #define DsaVerify wc_DsaVerify
sPymbed 0:1387ff3eed4a 41 #define DsaPublicKeyDecode wc_DsaPublicKeyDecode
sPymbed 0:1387ff3eed4a 42 #define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode
sPymbed 0:1387ff3eed4a 43 #define DsaKeyToDer wc_DsaKeyToDer
sPymbed 0:1387ff3eed4a 44
sPymbed 0:1387ff3eed4a 45 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 46 extern "C" {
sPymbed 0:1387ff3eed4a 47 #endif
sPymbed 0:1387ff3eed4a 48
sPymbed 0:1387ff3eed4a 49
sPymbed 0:1387ff3eed4a 50 enum {
sPymbed 0:1387ff3eed4a 51 DSA_PUBLIC = 0,
sPymbed 0:1387ff3eed4a 52 DSA_PRIVATE = 1
sPymbed 0:1387ff3eed4a 53 };
sPymbed 0:1387ff3eed4a 54
sPymbed 0:1387ff3eed4a 55 /* DSA */
sPymbed 0:1387ff3eed4a 56 typedef struct DsaKey {
sPymbed 0:1387ff3eed4a 57 mp_int p, q, g, y, x;
sPymbed 0:1387ff3eed4a 58 int type; /* public or private */
sPymbed 0:1387ff3eed4a 59 void* heap; /* memory hint */
sPymbed 0:1387ff3eed4a 60 } DsaKey;
sPymbed 0:1387ff3eed4a 61
sPymbed 0:1387ff3eed4a 62 WOLFSSL_API int wc_InitDsaKey(DsaKey* key);
sPymbed 0:1387ff3eed4a 63 WOLFSSL_API int wc_InitDsaKey_h(DsaKey* key, void* h);
sPymbed 0:1387ff3eed4a 64 WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
sPymbed 0:1387ff3eed4a 65 WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out,
sPymbed 0:1387ff3eed4a 66 DsaKey* key, WC_RNG* rng);
sPymbed 0:1387ff3eed4a 67 WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig,
sPymbed 0:1387ff3eed4a 68 DsaKey* key, int* answer);
sPymbed 0:1387ff3eed4a 69 WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx,
sPymbed 0:1387ff3eed4a 70 DsaKey*, word32);
sPymbed 0:1387ff3eed4a 71 WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
sPymbed 0:1387ff3eed4a 72 DsaKey*, word32);
sPymbed 0:1387ff3eed4a 73 WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen);
sPymbed 0:1387ff3eed4a 74
sPymbed 0:1387ff3eed4a 75 #ifdef WOLFSSL_KEY_GEN
sPymbed 0:1387ff3eed4a 76 WOLFSSL_API int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa);
sPymbed 0:1387ff3eed4a 77 WOLFSSL_API int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa);
sPymbed 0:1387ff3eed4a 78 #endif
sPymbed 0:1387ff3eed4a 79
sPymbed 0:1387ff3eed4a 80 /* raw export functions */
sPymbed 0:1387ff3eed4a 81 WOLFSSL_API int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p,
sPymbed 0:1387ff3eed4a 82 const char* q, const char* g);
sPymbed 0:1387ff3eed4a 83 WOLFSSL_API int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz,
sPymbed 0:1387ff3eed4a 84 byte* q, word32* qSz, byte* g,
sPymbed 0:1387ff3eed4a 85 word32* gSz);
sPymbed 0:1387ff3eed4a 86 WOLFSSL_API int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y,
sPymbed 0:1387ff3eed4a 87 word32* ySz);
sPymbed 0:1387ff3eed4a 88 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 89 } /* extern "C" */
sPymbed 0:1387ff3eed4a 90 #endif
sPymbed 0:1387ff3eed4a 91
sPymbed 0:1387ff3eed4a 92 #endif /* NO_DSA */
sPymbed 0:1387ff3eed4a 93 #endif /* WOLF_CRYPT_DSA_H */
sPymbed 0:1387ff3eed4a 94
sPymbed 0:1387ff3eed4a 95