1
/* Copyright (C) 2009, 2010 Simon Josefsson
2
* Copyright (C) 2006, 2007 The Written Word, Inc. All rights reserved.
3
* Copyright (C) 2010 Daniel Stenberg
5
* Redistribution and use in source and binary forms,
6
* with or without modification, are permitted provided
7
* that the following conditions are met:
9
* Redistributions of source code must retain the above
10
* copyright notice, this list of conditions and the
11
* following disclaimer.
13
* Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials
16
* provided with the distribution.
18
* Neither the name of the copyright holder nor the names
19
* of any other contributors may be used to endorse or
20
* promote products derived from this software without
21
* specific prior written permission.
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
38
#ifndef LIBSSH2_CRYPTO_H
39
#define LIBSSH2_CRYPTO_H
41
#ifdef LIBSSH2_LIBGCRYPT
42
#include "libgcrypt.h"
47
int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
48
const unsigned char *edata,
50
const unsigned char *ndata,
52
const unsigned char *ddata,
54
const unsigned char *pdata,
56
const unsigned char *qdata,
58
const unsigned char *e1data,
60
const unsigned char *e2data,
62
const unsigned char *coeffdata, unsigned long coefflen);
63
int _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
64
LIBSSH2_SESSION * session,
66
unsigned const char *passphrase);
67
int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx * rsa,
68
const unsigned char *sig,
69
unsigned long sig_len,
70
const unsigned char *m, unsigned long m_len);
71
int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session,
72
libssh2_rsa_ctx * rsactx,
73
const unsigned char *hash,
75
unsigned char **signature,
76
size_t *signature_len);
79
int _libssh2_dsa_new(libssh2_dsa_ctx ** dsa,
80
const unsigned char *pdata,
82
const unsigned char *qdata,
84
const unsigned char *gdata,
86
const unsigned char *ydata,
88
const unsigned char *x, unsigned long x_len);
89
int _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
90
LIBSSH2_SESSION * session,
92
unsigned const char *passphrase);
93
int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
94
const unsigned char *sig,
95
const unsigned char *m, unsigned long m_len);
96
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
97
const unsigned char *hash,
98
unsigned long hash_len, unsigned char *sig);
101
int _libssh2_cipher_init(_libssh2_cipher_ctx * h,
102
_libssh2_cipher_type(algo),
104
unsigned char *secret, int encrypt);
106
int _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
107
_libssh2_cipher_type(algo),
108
int encrypt, unsigned char *block, size_t blocksize);
110
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
111
unsigned char **method,
113
unsigned char **pubkeydata,
114
size_t *pubkeydata_len,
115
const char *privatekey,
116
const char *passphrase);
118
void _libssh2_init_aes_ctr(void);