version 1.11, 1999/12/06 19:11:15 |
version 1.12, 2000/04/04 21:37:27 |
|
|
/* Allocate space for the private part of the key in the buffer. */ |
/* Allocate space for the private part of the key in the buffer. */ |
buffer_append_space(&encrypted, &cp, buffer_len(&buffer)); |
buffer_append_space(&encrypted, &cp, buffer_len(&buffer)); |
|
|
cipher_set_key_string(&cipher, cipher_type, passphrase, 1); |
cipher_set_key_string(&cipher, cipher_type, passphrase); |
cipher_encrypt(&cipher, (unsigned char *) cp, |
cipher_encrypt(&cipher, (unsigned char *) cp, |
(unsigned char *) buffer_ptr(&buffer), |
(unsigned char *) buffer_ptr(&buffer), |
buffer_len(&buffer)); |
buffer_len(&buffer)); |
|
|
xfree(buffer_get_string(&buffer, NULL)); |
xfree(buffer_get_string(&buffer, NULL)); |
|
|
/* Check that it is a supported cipher. */ |
/* Check that it is a supported cipher. */ |
if (((cipher_mask() | SSH_CIPHER_NONE | SSH_AUTHFILE_CIPHER) & |
if (((cipher_mask1() | SSH_CIPHER_NONE | SSH_AUTHFILE_CIPHER) & |
(1 << cipher_type)) == 0) { |
(1 << cipher_type)) == 0) { |
debug("Unsupported cipher %.100s used in key file %.200s.", |
debug("Unsupported cipher %.100s used in key file %.200s.", |
cipher_name(cipher_type), filename); |
cipher_name(cipher_type), filename); |
|
|
buffer_append_space(&decrypted, &cp, buffer_len(&buffer)); |
buffer_append_space(&decrypted, &cp, buffer_len(&buffer)); |
|
|
/* Rest of the buffer is encrypted. Decrypt it using the passphrase. */ |
/* Rest of the buffer is encrypted. Decrypt it using the passphrase. */ |
cipher_set_key_string(&cipher, cipher_type, passphrase, 0); |
cipher_set_key_string(&cipher, cipher_type, passphrase); |
cipher_decrypt(&cipher, (unsigned char *) cp, |
cipher_decrypt(&cipher, (unsigned char *) cp, |
(unsigned char *) buffer_ptr(&buffer), |
(unsigned char *) buffer_ptr(&buffer), |
buffer_len(&buffer)); |
buffer_len(&buffer)); |