mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: Add dedicated private key functions to name-value.c.
* common/name-value.c (struct name_value_container): Add field 'private_key_mode'. (my_error): New. Use instead of gpg_error. (nvc_new_private_key): New. (nve_release): Add arg 'private_key_mode'. (nvc_release): Call nve_release with private_key_mode flag. (nvc_delete): Ditto. (_nvc_add): Do no special case "Key:" in non-private_key_mode. (nvc_get_private_key): Return error in non-private_key_mode. (nvc_set_private_key): Ditto. (nvc_parse): Factor all code out to ... (do_nvc_parse): new. Add arg 'for_private_key'. (nvc_parse_private_key): New. * agent/findkey.c (write_extended_private_key): Replace nvc_parse by nvc_parse_private_key. (read_key_file): Ditto. * common/t-name-value.c (private_key_mode): New variable. (my_nvc_new): New. Replace all callers. (test_key_extraction): Take mode in account. (run_tests): Ditto. (run_modification_tests): Ditto. (parse): Ditto. (main): Add option --parse and rename --parse to --parse-key. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d74d23d860
commit
3ead21da80
4 changed files with 153 additions and 44 deletions
|
@ -40,10 +40,14 @@ typedef struct name_value_entry *nve_t;
|
|||
|
||||
/* Memory management, and dealing with entries. */
|
||||
|
||||
/* Allocate a private key container structure. */
|
||||
/* Allocate a name value container structure. */
|
||||
nvc_t nvc_new (void);
|
||||
|
||||
/* Release a private key container structure. */
|
||||
/* Allocate a name value container structure for use with the extended
|
||||
* private key format. */
|
||||
nvc_t nvc_new_private_key (void);
|
||||
|
||||
/* Release a name value container structure. */
|
||||
void nvc_release (nvc_t pk);
|
||||
|
||||
/* Get the name. */
|
||||
|
@ -103,6 +107,13 @@ gpg_error_t nvc_set_private_key (nvc_t pk, gcry_sexp_t sexp);
|
|||
parser was last considering is stored there. */
|
||||
gpg_error_t nvc_parse (nvc_t *result, int *errlinep, estream_t stream);
|
||||
|
||||
/* Parse STREAM and return a newly allocated name value container
|
||||
structure in RESULT - assuming the extended private key format. If
|
||||
ERRLINEP is given, the line number the parser was last considering
|
||||
is stored there. */
|
||||
gpg_error_t nvc_parse_private_key (nvc_t *result, int *errlinep,
|
||||
estream_t stream);
|
||||
|
||||
/* Write a representation of PK to STREAM. */
|
||||
gpg_error_t nvc_write (nvc_t pk, estream_t stream);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue