| 1 |
/* |
| 2 |
* Copyright (c) 1998-2001, Robert O'Callahan |
| 3 |
* (C) 2004- TeraTerm Project |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
| 7 |
* modification, are permitted provided that the following conditions |
| 8 |
* are met: |
| 9 |
* |
| 10 |
* 1. Redistributions of source code must retain the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer. |
| 12 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
* documentation and/or other materials provided with the distribution. |
| 15 |
* 3. The name of the author may not be used to endorse or promote products |
| 16 |
* derived from this software without specific prior written permission. |
| 17 |
* |
| 18 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| 19 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 |
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
*/ |
| 29 |
|
| 30 |
/* |
| 31 |
This code is copyright (C) 1998-1999 Robert O'Callahan. |
| 32 |
See LICENSE.TXT for the license. |
| 33 |
*/ |
| 34 |
|
| 35 |
#ifndef __KEYFILES_H |
| 36 |
#define __KEYFILES_H |
| 37 |
|
| 38 |
typedef enum { |
| 39 |
SSH2_KEYFILE_TYPE_NONE, |
| 40 |
SSH2_KEYFILE_TYPE_OPENSSH, |
| 41 |
SSH2_KEYFILE_TYPE_PUTTY, |
| 42 |
SSH2_KEYFILE_TYPE_SECSH |
| 43 |
} ssh2_keyfile_type; |
| 44 |
|
| 45 |
Key * KEYFILES_read_private_key(PTInstVar pvar, |
| 46 |
char * relative_name, |
| 47 |
char * passphrase, |
| 48 |
BOOL * invalid_passphrase, |
| 49 |
BOOL is_auto_login); |
| 50 |
|
| 51 |
Key *read_SSH2_private_key(PTInstVar pvar, |
| 52 |
FILE * fp, |
| 53 |
char * passphrase, |
| 54 |
BOOL * invalid_passphrase, |
| 55 |
BOOL is_auto_login, |
| 56 |
char *errmsg, |
| 57 |
int errmsg_len); |
| 58 |
|
| 59 |
Key *read_SSH2_PuTTY_private_key(PTInstVar pvar, |
| 60 |
FILE * fp, |
| 61 |
char * passphrase, |
| 62 |
BOOL * invalid_passphrase, |
| 63 |
BOOL is_auto_login, |
| 64 |
char *errmsg, |
| 65 |
int errmsg_len); |
| 66 |
|
| 67 |
Key *read_SSH2_SECSH_private_key(PTInstVar pvar, |
| 68 |
FILE * fp, |
| 69 |
char * passphrase, |
| 70 |
BOOL * invalid_passphrase, |
| 71 |
BOOL is_auto_login, |
| 72 |
char *errmsg, |
| 73 |
int errmsg_len); |
| 74 |
|
| 75 |
ssh2_keyfile_type get_ssh2_keytype(char *relative_name, |
| 76 |
FILE **fp, |
| 77 |
char *errmsg, |
| 78 |
int errmsg_len); |
| 79 |
|
| 80 |
/* openssh private key file format */ |
| 81 |
#define MARK_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----\n" |
| 82 |
#define MARK_END "-----END OPENSSH PRIVATE KEY-----\n" |
| 83 |
#define KDFNAME "bcrypt" |
| 84 |
#define AUTH_MAGIC "openssh-key-v1" |
| 85 |
#define SALT_LEN 16 |
| 86 |
#define DEFAULT_CIPHERNAME "aes256-cbc" |
| 87 |
#define DEFAULT_ROUNDS 16 |
| 88 |
|
| 89 |
#define MAX_KEY_FILE_SIZE (1024 * 1024) |
| 90 |
|
| 91 |
#endif |