Lines Matching refs:buffer
63 #include "buffer.h"
85 key_private_rsa1_to_blob(Key *key, Buffer *blob, const char *passphrase,
88 Buffer buffer, encrypted;
104 /* This buffer is used to built the secret part of the private key. */
105 buffer_init(&buffer);
113 buffer_append(&buffer, buf, 4);
120 buffer_put_bignum(&buffer, key->rsa->d);
121 buffer_put_bignum(&buffer, key->rsa->iqmp);
122 buffer_put_bignum(&buffer, key->rsa->q); /* reverse from SSL p */
123 buffer_put_bignum(&buffer, key->rsa->p); /* reverse from SSL q */
126 while (buffer_len(&buffer) % 8 != 0)
127 buffer_put_char(&buffer, 0);
129 /* This buffer will be used to contain the data in the file. */
147 /* Allocate space for the private part of the key in the buffer. */
148 cp = buffer_append_space(&encrypted, buffer_len(&buffer));
153 buffer_ptr(&buffer), buffer_len(&buffer));
159 buffer_free(&buffer);
169 key_private_pem_to_blob(Key *key, Buffer *blob, const char *_passphrase,
219 key_save_private_blob(Buffer *keybuf, const char *filename)
239 /* Serialise "key" to buffer "blob" */
241 key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
261 Buffer keyblob;
279 key_parse_public_rsa1(Buffer *blob, char **commentp)
282 Buffer copy;
292 * from the buffer.
307 /* Read the public key from the buffer. */
320 /* Load a key from a fd into a buffer */
322 key_load_file(int fd, const char *filename, Buffer *blob)
383 Buffer buffer;
386 buffer_init(&buffer);
387 if (!key_load_file(fd, filename, &buffer)) {
388 buffer_free(&buffer);
392 pub = key_parse_public_rsa1(&buffer, commentp);
395 buffer_free(&buffer);
418 key_parse_private_rsa1(Buffer *blob, const char *passphrase, char **commentp)
421 Buffer decrypted;
426 Buffer copy;
436 * from the buffer.
451 /* Read the public key from the buffer. */
473 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
519 key_parse_private_pem(Buffer *blob, int type, const char *passphrase,
599 Buffer buffer;
602 buffer_init(&buffer);
603 if (!key_load_file(fd, NULL, &buffer)) {
604 buffer_free(&buffer);
607 prv = key_parse_private_pem(&buffer, type, passphrase, commentp);
608 buffer_free(&buffer);
641 key_parse_private_type(Buffer *blob, int type, const char *passphrase,
665 Buffer buffer;
685 buffer_init(&buffer);
686 if (!key_load_file(fd, filename, &buffer)) {
687 buffer_free(&buffer);
692 ret = key_parse_private_type(&buffer, type, passphrase, commentp);
693 buffer_free(&buffer);
698 key_parse_private(Buffer *buffer, const char *filename,
704 pub = key_parse_public_rsa1(buffer, commentp);
706 prv = key_parse_private_type(buffer, KEY_UNSPEC,
714 prv = key_parse_private_type(buffer, KEY_RSA1, passphrase,
725 Buffer buffer;
740 buffer_init(&buffer);
741 if (!key_load_file(fd, filename, &buffer)) {
742 buffer_free(&buffer);
748 prv = key_parse_private(&buffer, filename, passphrase, commentp);
749 buffer_free(&buffer);