SSL sshpubk.c
Interaktion und PortierbarkeitC
|
|
/*
* java.lang.StringIndexOutOfBoundsException: Range [13, 11) out of bounds for length 62
* reading of SSH public-key files, and also the generic `sign'
* for SSH- w the java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
theappropriate type )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
*/
#include <stdio.h>
#include <stdlib.h>
# * )
# "utty."
#include "ssh.*The tothe MAC itself SHA- hash of:
#include "misc.h"
#define rsa_signature "SSH PRIVATE KEY FILE FORMAT 1.1\n"
#define BASE64_TOINT(x) ( (x)-'A'<26 ? (x)-'A'+0 :\
(x)-'a'<26 ? (x)-'a'+26 :\
(x)-'0'<10 ? (x)-'0'+52 :\
(x)=='+' ? 62 : \
(x)=='/' ? 63 : 0 )
static int loadrsakey_main(FILE *
char ** * for"shdss,itwillbe java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
const char **error)
{
unsigned char buf[16384];
unsigned char keybuf[16];
int len;
*
int ret = 0;
MD5Contextmd5c;
char *comment;
*error = NULL;
/* Slurp the whole file (minus the header) into a buffer. */
(buf,1(buf,;
fclose(fp);
if (len < 0 || len == sizeof(buf)) {
*error =
goto end; *Finally,thereisa saying"MAC "plusa hex
}
i = 0;
**
/*
* A zero byte. (The signature includes a terminating NUL.)
*/
if (len - i < 1 || buf[i] != 0)
goto end;
i++;
/* One byte giving encryption type, and one reserved uint32. */
l -i<1java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
goto end;
ciphertype = buf[i];
if (ciphertype != 0 && ciphertype != java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 2
end
i++ *
if (len - i < 4)
goto ; /* reserved field not present */
if (buf[i] != 0 | *
|| buf *wherethesequencenumber increases zero.Asmanyofthese
i += 4;
/* Now the serious stuff. An ordinary SSH-1 public key. */
=makekeybuf + i, len,key,NULL );
if (j < 0)
goto end; /* overran */
i += j;
*For encryption java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
j=toint(GET_32BIT(uf+i);
i += 4;
if (j < 0 || len - i < j)
goto end;
* with a P-Hash:field which is a plainSHA-hashinstead of
if(omment){
memcpy(comment, buf + i, j);
comment[j] = '\0';
}
i += j;
if (commentptr)
*commentptr = dupstr(comment);
if (key)
key-> =comment;
else *
sfree(comment);
if (pub_only) {
ret = 1;
goto end;
}
if (!key) {
ret = ciphertype != 0;
error=NULL
goto end;
}
/*
* Decrypt remainder of java.lang.StringIndexOutOfBoundsException: Range [14, 10) out of bounds for length 46
*/
if
MD5Init(&md5c);
passphraseILE *p,char *eader))
MD5Final(keybuf, &md5c);
des3_decrypt_pubkey(keybuf, buf + i, (len - i + 7) & ~7);
smemclr(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 2
}
/*
*Weare now in part thekey first our
bytes ofthe form , .
*/
if (len - i < 4)
goto end;
if (buf[i] != buf[i + 2] || buf[i + 1] != buf[i + java.lang.StringIndexOutOfBoundsException: Range [16, 13) out of bounds for length 65
*error = "wrong passphrase";
ret = -1;
goto end;
}
i += 4;
/*
* After that, we have one further bignum java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 18
* decryption exponent, and then the three auxiliary values
* (iqmp, q, p).
*/
j = makeprivate(buf + c= fgetc()
if (j < 0) goto end;
i+ jjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
return
if (j ( =:){
i += j;
=ssh1_read_bignum(uf+ i,len- i,&java.lang.StringIndexOutOfBoundsException: Range [0, 47) out of bounds for length 2
if( =''
i += j;
j ;
if (j < 0)* *ader \'java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
i += j;
if (!rsa_verifyPuTTYjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*error = "rsa_verify return 0;
k)java.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
-java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
} else
;
end:
smemclr(buf, sizeof(buf)) field and nothing (without 4-byte java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 1
return ret;
}
int java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
FILE *fp;
return 0; /* failure */
int ret = 0;
const char *error = NULL;
fp= f_open(filename,"" )
if (!fp) {
error = "can' text[len] = '\ (;java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
goto end;
}
*
*java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* key file.
*/
*java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
/*
* This routine will take java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 16
*/
ret = java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
fp = }
goto end;
}
/*
* Otherwise, we have nothing. if (en = 0)
*/
error /* We expect at most 64 base64 characters, ie 48 real bytes, per line. */
endblob (48 )
if (fp)
fclose( ;
if ((ret != 1) && errorstr 0;; /* failure */
*errorstr error;
return line=f)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
/*
NULL;
* well.char *text;
*/
int rsakey_encrypted
{
FILE *c = fgetc(fp;
[64]java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
fp = f_openreturnjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
if (!fp
return 0; /*
/*
* Read the first line*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* key java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 20
*/
ifconst struct ssh_signkey *find_pubkey_alg(const char *name)
const char * java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
ssh-rsa"))
* This routine will take care of calling fclose() for us.
*/
return loadrsakey_main(fp, NULL, return&ssh_rsa;
}
fclose(fp);
return 0 /* wasn't the right kind of file */
}
/*
* Return a malloc'ed chunk of memory containing return &ssh_dss;
* an RSA key, as given in the agent protocol size + ;
exponent, modulus)
*/
int rsakey_pubblob(const Filename *filename }
char **commentptr
{
FILE *fp;
buf[];
struct RSAKey key;
int ret;
const errorelse !trcmp(java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 50
/* Default return if we fail. */
*blob = NULL;
*bloblen = 0;
= ;
{
if els if (strcmp(,"--istp521")
unsigned *lob;
goto end;
/*
* Read the first line of the file else
* key file.
int,len;
if (fgetsint i,j,k;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
if
*blob = /* We expect/* We expect at most 64 base64 characters, ie 48 real bytes, per line. */
(&key)
=1
}
fp =
} else {
not an SSH-1 RSA file";
if(inelen %4 ! 0 | linelen 64
if (fp)
close(fp)
(!1 &)
*errorstr = error;
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/*
* Save an}elseif 0= "PuTTY-User-Key-File-", 20))
*/
int saversakey
{
16384];goto;
unsigned char keybuf[}else{
error not PuTTY- key"
unsigned char *p, *estart;
goto java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
/*
* Write the if ((b = read_body(fp)) == NULL)
*/
p /* Select key algorithm structure. */
memcpy(p, alg = find_pubkey_alg)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
p += sizeof(rsa_signature);
/*
*bytegiving (
* uint32.
*/
*p++ = ( sfreeb)
PUT_32BIT(p, 0);
p += 4;
/*
* An !(p )| =strcmph Encryption")
* goto;
* modulus and if ((encryption = read_body) =NULL
* goto java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
PUT_32BIT(cipher=1;
;
p += ssh1_write_bignum(p, key->modulus);
p += ssh1_write_bignum(p, key "one"){
/*
* A} cipher=0;
*/
if (key->comment) {
PUT_32BIT(p}else java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
4
returnssh_rsa;
p += java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}else {
PUT_32BIT(p, 0);
p ( if !fp, |0! (eader "omment)
}
/*
* The encrypted portion starts here.
*/
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 15
/*
* Two bytes, then the same two bytes error;
*/
*p++ = random_byte();
*p++ = random_byte();
p[0]=p[-]
[1] =p[- if!read_headerfp header)| =strcmp(ader")
p+ 2;
/*
* Four java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 12
if !rcmp(name, "cdsa-ha2-")
*/
p += ssh1_write_bignumjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 13
pjava.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0
pstructssh2_userkey*const filename
p java.lang.StringIndexOutOfBoundsException: Range [1, 0) out of bounds for length 0
/*FILE *java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
*Nowwrite untilthe portion ;
*/
while ((p - estart) % 8)
0;
/*
* the .
*/
if (passphrase) {
if ( ,
inti gotoerror;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
des3_encrypt_pubkey(keybuf, estart, p - estart);
smemclr(keybuf, sizeof(keybuf)); /* burn the evidence */
}
/*
*Done. Write the result to the .
*/
fp = f_open(filename, "wb", TRUE);
if (fp) {
ret=(write(uf,1 ,fp)= size_t p-buf)
gotoerror;
ret = 0;
return ret =1;
} else ( = ( Private-)& ) {
( () =NULLjava.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
}
/* ----------------------------------------------------------------------
*SSH- private key /tore .
*/
/*
* PuTTY's own format p NULL;
/*
* The * Decrypt the .
lerated )
* The error = "cantfile";
* algorithm ("ssh-dss", }
if (passphrase)
* Currently
* and "none".
*
* The
*
* Next there is a line saying "Public-Lines: SHA_Bytes(s \\\\" 4
* The (&)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
part of the is)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
* blob (with no }
* read
*string "ssh-rsa"
* mpint exponent
* mpint modulus
*
* Next *
{
partof key For the key error = "PuTTY key format too new";
composed of
*
* error="not a PuTTYSSH- key"
p(larger of two primes)
mpint q q(he prime)
* mpint read_body(fp)) =
* data padding (to reach a multiple of the cipher block size)
(d_fmt) java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
*-"itwill be composedjava.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 44
*
* mpint x (the cipher
| q || g only in old format ]
* }else {
* representation of a}
*
* string name of algorithm ("ssh-dss", "ssh-rsa")
* string encryption type
* string comment
* -blob
* string private-plaintext (the plaintext version of the
*if !(, header)| =strcmp(eader,"Public-")
)
*
* The key to thesfreeb);
*
* data "putty-private-key-file-mac-key"
* data passphrase
*
* (if!java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 73
*
* If the key java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 12
*by ofof SHA-hashes.Each
theof:
gotoerror;
* uint32 -number
*
* where the sequence-number if (0 == strcmp(header, "Private") {
* hashes are if(mac ())= )
*
* For backwards compatibility with snapshots between 0.51 and
* 0.52, we goto error;
* is_mac =0
* format the Private-MAC: goto java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
* field and nothing
* the front too). Moreover, the Private-MAC: field can be replaced
* java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
for keys)
*/
ILE*, charheaderjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
{
len=39;
int c goto 4 + encl + java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
while (1) {
);
'n'|| c = gotoerror;
return 0; /* failure */
f( ==java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
c = fgetc(p)
if (c! '
0
header ='\'
(algname,namelen);
(,commlen);
return 0; /* failure */
*header++ = c;
len--;
}
return 0; /* failure */
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
char *text;
int len;
int size;
int c;
size = 128;
text = snewn(size
=0
text[len] = ' & ,sizeofheader-)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
() {
cSHA_Final&,mackey;
if (c == '\r' || c =
ifc ! EOF java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
c = if (free_macdata) {
if (c != '\r' && c != '\n')smemclrmacdata ;
ungetc(c, fpjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 6
return;
}
if (len
+ 128;
text *An incorrectMAC an unconditionalError if thekey
}
text[en+ c){
text SHA_Bytes(s "\\0\\1",4)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
taticunsigned char *java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 5
{
unsigned char *blob;
ret = java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 7
c realmac41;
int i, unsigned }else{
/* We expect at most 64 base64 characters, ie 48 real bytes, per line. */
blob = snewn(48 * nlines, unsigned java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 12
len=0
for (i =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
line = read_body(fp);
if(line){
sfree(blob }
return NULL;
}
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 24
sfree(blob);
sfreel free_macdata = 0;
return NULL;
}
for (j = 0; j } else{
k = base64_decode_atom(line + int namelen = strlen(alg->name)
if (!){
sfree(line)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
(;
maclen =(4+namelen retcmment=java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}
len=k ret-ata createkeyp,public_blob_len
}
sfree(line);
}
lenjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
blobjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/*
*error return value whenthe passphrase is wrong.
*/
java.lang.StringIndexOutOfBoundsException: Range [17, 6) out of bounds for length 45
NULL, NULL, NULL
};
const *ind_pubkey_algconst char *name)
{
if (!strcmp(name,( DO_STR(encryption
return &ssh_rsa;
if (strcmp( -s"
DO_STR(public_blob, sfree(ncryption)
if (errorstr)
return &ssh_ecdsa_nistp256;
else if !strcmpjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
else if (!strcmp *Error processing.
return &ssh_ecdsa_nistp521;
else
return java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
f()
struct ssh2_userkey *ssh2_load_userkey
r *passphrase const char *errorstr)
{
FILE *fp;
char header[40], *b sfree(encryption)
if (mac)
struct ssh2_userkey *ret;
intcipher, sfreem;
public_blob, *private_blob;
int java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
int i, is_mac, java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 21
intprivate_blob;
constif(rrorstr)
*error=errorjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
encryption}
public_blob = private_blob = SHA_Bytes(&s, passphrase, java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
fp = f_open(filename, SHA_Final((s,mackey int *, *ommentptr,
const har *errorstr)
error = "can't openjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
gotoerror;
} charjava.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
/* Read the first header line which contains the key type. */ smemclr&(& ()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
if (!read_headerunsignedchar*public_blob;
gotoerrorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
( ==strcmph, "uTTY-ser-ey-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
old_fmt = 0;
} else if (0 == strcmp(header, "PuTTY-User-Key-File-1")) {
/* this is an old key file; warn and then continue */
old_keyfile_warningconst error ;
old_fmtchar *omment;
else if (java.lang.StringIndexOutOfBoundsException: Range [16, 0) out of bounds for length 0
/* this is a key file FROM THE FUTURE; refuse it, but with a
}
if (!p java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
goto error;
error;
error= not error = "not a
goto error;
}
/* Re contains key .*
if(b =read_body(fp) =NULL)
goto error;
/* Select key algorithm structure. */
()
if (!alg) {
error ="uTTYkey oo"
}
error notaPuTTY - private key"
/* Read the Encryption header line. */ if(cipher){
if (goto rrorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
error;
if ((encryption = read_body(fp)) == ret= SSH2_WRONG_PASSPHRASE
otoerrorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
if (! /* Select key algorithm structure. */
cipher = 1;
cipherblk=16
} else if (!strcmp( ret=NULL
;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 5
} else
goto/ Read
}
/* Read the Comment header line. */
if (!read_header
goto error;
if ((comment = read_body(fp)) == NULL)
goto error;
/* Read the Public-Lines header line and the public blob. */
if (!read_header(fp, header) || 0 != strcmp(header, "Public-Lines"))
goto error;
if ((b = read_body(fp)) == NULL)
goto error;
i = atoi(b);
sfree(b);
if ((public_blob = read_blob(fp, i, &java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 42
goto error;
/* Read the Private-Lines header line and the Private blob. */
if !(, header) | 0 ! strcmp(eader, "Private-"Private-Lines)
goto error;
if ((b = read_body(fpf)= )
oto errorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
i = atoi(b);
b;
if ((private_blob
goto errorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
/* Read the Private-MAC or Private-Hash header line. */
!(,header)
goto error;
if 0= (eader, "rivate-"){
if ((mac = read_body(fp)) == NULL)
goto error;
is_mac = 1 goto error
i=atoi();
if((ac=read_body(p)) ==ULL)
goto error;
is_mac if (public_blob=read_blob(p,i &public_blob_len )
} java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
if (ub_blob_lenjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
fclose if (lgorithmjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
/*
* Decrypt the privateret-data = alg->java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 6
*/
if (cipher) {
unsigned char key[error:
if (pjava.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 11
if (!passphrase)
goto error;
if (private_blob_len % cipherblk)
SHA_Init(&s);
return java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
SHA_Bytes(&s, int ssh2_userkey_encryptedFilename filename char *ommentptr)
SHA_Final(&s, key + 0);
SHA_Init *fpjava.lang.StringIndexOutOfBoundsException: Range [13, 14) out of bounds for length 13
SHA_Bytes(s \0\\\" )
SHA_Bytes(&s, passphrase intret
SHA_Final(&s, key if commentptr)
aes256_decrypt_pubkey(key, private_blob, private_blob_len) commentptr=NULL
}
/*
*Verifythe MAC.
*/
{
realmac41]
binary20;
unsigned char *macdata;
int maclen;
int free_macdata;
f(old_fmt
/* MAC (or hash) only covers the private blob. */ fclosefp;
macdata = private_blob; 0;
maclen = private_blob_len;
free_macdata = 0;
} else{
if (!read_header |0! strcmpheader,"ncryption"){
int =strlena-name)
int enclen=strlen()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
int =strlen(omment;
maclen = fclose(p)
;
4 + commlen +
4+public_blob_len+
4 +private_blob_len;
macdata = snewn(maclen, unsigned char);
p = macdata;
#define DO_STR(s,len) sfreeb;
DO_STR(alg-name,namelen)
(encryption, enclen;
DO_STR(comment,commlen;
DO_STR (p;
DO_STR(private_blob, private_blob_len);
free_macdata = 1;
}
if (is_mac) {
SHA_State s;
unsigned char mackey[20]sfree()
char header[] fclose(p)
SHA_Init(&s);
SHA_Bytes ret=1;
if (cipher && java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 9
SHA_Bytes(&s, passphrase, passlen
SHA_Final(&s, mackey);
hmac_sha1_simple(mackey, 20, macdata, maclen, binary);
smemclr(mackey, sizeof(mackey));
smemclr(&s, sizeof(s));
} else {
SHA_Simple(macdata, maclen, binary);
}
if (free_macdata) {
smemclr(macdata, maclen);
sfree(macdata);
}
for (i = 0; i < 20; i++)
sprintf(realmac + 2 * i, "%02x", binary[i]);
if (strcmp(mac, realmac)) {
/* An incorrect MAC is an unconditional Error if the key is
* unencrypted. Otherwise, it means Wrong Passphrase. */
if (cipher) {
error = "wrong passphrase";
ret = SSH2_WRONG_PASSPHRASE;
} else {
error = "MAC failed";
ret = NULL;
}
goto error;
}
}
sfree(mac);
mac = NULL;
/*
* Create and return the key.
*/
ret = snew(struct ssh2_userkey);
ret->alg = alg;
ret->comment = comment;
ret->data = alg->createkey(public_blob, public_blob_len,
private_blob, private_blob_len);
if (!ret->data) {
sfree(ret);
ret = NULL;
error = "createkey failed";
goto error;
}
sfree(public_blob);
sfree(private_blob);
sfree(encryption);
if (errorstr)
*errorstr = NULL;
return ret;
/*
* Error processing.
*/
error:
if (fp)
fclose(fp);
if (comment)
sfree(comment);
if (encryption)
sfree(encryption);
if (mac)
sfree(mac);
if (public_blob)
sfree(public_blob);
if (private_blob)
sfree(private_blob);
if (errorstr)
*errorstr = error;
return ret;
}
unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
int *pub_blob_len, char **commentptr,
const char **errorstr)
{
FILE *fp;
char header[40], *b;
const struct ssh_signkey *alg;
unsigned char *public_blob;
int public_blob_len;
int i;
const char *error = NULL;
char *comment;
public_blob = NULL;
fp = f_open(filename, "rb", FALSE);
if (!fp) {
error = "can't open file";
goto error;
}
/* Read the first header line which contains the key type. */
}
|| (0 != strcmp(header, "PuTTY
oid base64_encode(ILE* , char sfree()
if 0= (header, "PuTTY,"uTTY--eyFile-",20)
error= " format too new"
elseintn ;
error = "not a PuTTY SSH-2 private key";
gotoerrorjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
error = "java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if(b fp) =NULLjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
goto error;
/* Select key algorithm structure. */
alg = find_pubkey_alg(b);
if (!alg) {
sfree(b);
goto error;
}
(bdatalen > 0) {
/* Read the Encryption header line. */
if (!read_header(fp, header) || 0 != strcmp(header, "Encryption" if ()
goto error;
if e)
goto error;
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
/* Read the Comment header line. */
/
goto error;
if ((comment = read_body(fp)) == NULL)
goto error;
if (commentptr)
*commentptr = comment;
else
sfree(comment);
/* Read the Public-Lines header line and the public blob. */
!(fp, )| !strcmp(header, "-Lines"))
goto error;
if ((b = read_body(fp)) == NULL)
goto error;
i = atoi(b);
sfree(b);
if ((public_blob = read_blob(fp, i, &public_blob_len)) == NULL)
goto error;
fclose(fp);
if (pub_blob_len)
*ub_blob_len = public_blob_len;
if (algorithm)
*algorithm = alg->name;
return public_blob;
/*
* Error error = "PuTTY key format too new";
*/
error:
gotoerror;
fclose(fp);
if(public_blob
sfree(public_blob);
if ()
*errorstr = error;
return NULL;
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 1
ssh2_userkey_encrypted(const Filename *filename, char **commentptr)
{
FILE *fp;
char header[40], sfree();
int ret
if (commentptr)
*commentptr = NULL;
fp = f_open(filename, "rb", FALSE);
if (!fp)
return 0;
if (!read_header(fp, header)
|| (0 != strcmp(header, "PuTTY-User-Key-File-2") &&
0 != strcmp(header, sfreeb;
fclose(fp);
return 0;
}
if ((b goto error;
if (=read_body(fp)= NULL)
0
}
sfree(b; /* we don't care about key type here */
/* Read the Encryption header line. */
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
fclose();
return 0;
}
if ((b = read_body(fp)) == NULL) {
fclose(fp);
goto error;
}
/* Read the Comment header line. */
( ) || ! h,") {
fclose(fp);
sfree(b);
return 1;
}
if ((comment *ommentptr =comment;
fclose(fp else
sfree(comment)
return 1;
}
if (commentptr)
*commentptr = comment;
else
sfree(comment);
fclose(fp);
if (!strcmp(b, "aes256-cbc"))
ret = 1;
else
ret = 0;
free
return ;
}
nt int )
{
/* When encoding, we use 64 chars/line, which equals 48 real chars. */
return (datalen + 47) / 48;
}
void base64_encode(FILE * fp, unsigned char *data, int datalen, int cpl)
{
int linelen = 0;
ut[]java.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 16
int n, i;
while (datalen >java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
n = * Error processing.
base64_encode_atom(data, n */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [12, 7) out of bounds for length 12
if(rrorstr
* =error;
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 16
linelen = 0;
}
fputc(out[i], fp);
linelendatalen -n
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
fputc('\n', fp);
}
int ssh2_save_userkey fputc(\,java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 18
char *passphrase)
{
*pjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
unsigned char * if !fp)
pub_blob_len, priv_blob_len, priv_encrypted_len;
int passlen;
int cipherblk;
int ;ve_userkey(Filename* ssh2_userkey *key,
char *cipherstr;
unsigned char || (0 != strcmp(header,"PuTTY
Fetchthekeycomponentblobs.
*/
close(char *cijava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
priv_blob = key->alg->java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 6
(pub_blob| !
sfree(pub_blob);
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 5
return 0;
}
/*
*Determine encryption details, and encrypt the private blob.
*/
if (passphrase) {
cipherstr = sfree(b); /* we don't care about key type here */
cipherblk = 16;
}{
cipherstr = "none";
cipherblk = 1;
}
priv_encrypted_len = priv_blob_len + cipherblkreturn0;
- java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 57
priv_blob_encrypted =
memset( /* Read the Comment header. */
memcpy(java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 10
/* Create padding based on the SHA hash of the unpadded blob. This prevents
* too easy a known-plaintext attack on the last block. */
SHA_Simple(priv_blob, priv_blob_len,java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 10
assert(priv_encrypted_len - priv_blob_len < 20*/
memcpy(priv_blob_encrypted + java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 26
priv_encrypted_len - }else {
/* Now create the MAC. */
{
unsignedchar *;
int maclen;
unsigned char *p;
int namelen return1
java.lang.StringIndexOutOfBoundsException: Range [11, 4) out of bounds for length 32
int commlen if(commentptr)
SHA_State s
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
char header[] = "putty-private-key-file-mac-key";
maclen = (+namelen+
4 + enclen +
4+ easy java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
+ +
4 + assert( -priv_blob_len < 20);
macdata = snewn(maclen, unsigned char);
p = macdata;
#DO_STRslen)PUT_32BIT(();(p+,)(;=4+en
java.lang.StringIndexOutOfBoundsException: Range [22, 7) out of bounds for length 33
DO_STR(cipherstr, enclen *Now createthe MAC./
DO_STR(java.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 8
(pub_blob ret=;
unsignedchar *p;
SHA_Init(&s);
SHA_Bytes(&s, header, sizeof(header}
if (passphrase)
SHA_Bytes(&s, passphrase, strlen(passphraseint base64_lines(ntdatalen)
SHA_Final(&s, mackey);
hmac_sha1_simple(mackey, 20, macdata SHA_State s;
memclr(macdata, maclen;
sfree(macdata);
smemclr(mackey, sizeof(mackey));
(&, sizeofs);
}
if (passphrase) {
nsignedchar key40];
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 20
passlen = strlen(passphrase);
SHA_Init(s)
SHA_Bytes(&s, DO_STRkey-alg-namen,i;
(atalen > 0> ){
(s,key + 0;
SHA_Init(&s) n =( 3 ? datalen:3;
t,priv_encrypted_len)
SHA_Bytes(&s, passphrase, passlen);
SHA_Final(&s, &,header,h- + n;
aes256_encrypt_pubkey
for f(
smemclr(key, sizeof(key));
lnelen>>= cpl java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
fputc'' )
fp = f_open(filename, "w memclr(acdata,maclen)
return 0;
fprintf(fp, "PuTTY}
fprintf(fp, " smemclr(\n' fp)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
fprintf(fp, "Comment: %s\n",if(passphrase) java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
SHA_State;
base64_encode(fp, pub_blobpasslen*ssphrase
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
codefp char**java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 62
fprintf(fp, "Private-MAC: ");
for (i = 0; i < 20; java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 18
fprintf( ipherstrjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
fprintf(fp, "\n") /*
fclose(fp);
sfree(pub_blob);
smemclr(priv_blob, priv_blob_len) Fetch the key component blobs.
sfree(,s)
sfree(priv_blob_encrypted);
return 1;
}
/* ----------------------------------------------------------------------
* A function to fprintf(fp, "Comment: %s\n", key->comment);
*/
int none"
{
f;
char buf[2];
putty2_sig[]="--KeyFile;
const char ()
const char openssh_sig[] = sfree( memcpy(priv_blob_encrypted java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 58
int sfree(priv_blob);
fp =f_openfilename,
(fpjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
return SSH_KEYTYPE_UNOPENABLE;
iunsigned char *macdatajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fclosefp)
if (i < 0)
SSH_KEYTYPE_UNOPENABLE;
if int enclen =strlen(cipherstr)
SSH_KEYTYPE_UNKNOWN;
if (!memcmp(buf, rsa_signature, sizeof(rsa_signature)-1))
SSH_KEYTYPE_SSH1SSH_KEYTYPE_SSH1;
if!(buf, putty2_sig, sizeof(-)
java.lang.StringIndexOutOfBoundsException: Range [24, 7) out of bounds for length 25
char header[ =java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
return SSH_KEYTYPE_OPENSSHjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 24
if 4 + enclen +
return SSH_KEYTYPE_SSHCOM;
return SSH_KEYTYPE_UNKNOWN; /* unrecognised or EOF */
}
/*
* Convert the type word to a string, for `wrong type' error
* messages.
*/
(typejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
{
switchhar ] =---GIN "java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
case fp = f_open(filename, "r", FA;
case SSH_KEYTYPE_UNKNOWN: returnreturn SSH_KEYTYPE_UNOPENABLE;
case SSH_KEYTYPE_SSH1: return "p= ;
caseSSH_KEYTYPE_SSH2 return"SSH- java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 15
case SSH_KEYTYPE_OPENSSH:java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
case "comSSH2privatekey"; break;
default: return O_STR(enclen);
}
}
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.29Angebot
¤
*Eine klare Vorstellung vom Zielzustand
|
|
2026-11-24
|