aboutsummaryrefslogtreecommitdiff
path: root/include/olm/pk.h
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2018-10-12 08:24:45 +0100
committerGitHub <noreply@github.com>2018-10-12 08:24:45 +0100
commitb1130fb77f0bcaa436a5308bd1093b0e94aa6585 (patch)
tree0224871c07b0a98989e122c1937606a1857a2aa4 /include/olm/pk.h
parentb2d91f55ece853ca1a398d3c6814f18a3f10bee0 (diff)
parent50ed20f61e76c4569c001cf8acb6e5bc361957b3 (diff)
Merge pull request #61 from matrix-org/dbkr/pk_private_export_import
Work with PkDecryption keys by their private keys
Diffstat (limited to 'include/olm/pk.h')
-rw-r--r--include/olm/pk.h48
1 files changed, 39 insertions, 9 deletions
diff --git a/include/olm/pk.h b/include/olm/pk.h
index 8804d1f..4278fca 100644
--- a/include/olm/pk.h
+++ b/include/olm/pk.h
@@ -80,7 +80,7 @@ size_t olm_pk_encrypt_random_length(
* key. Returns olm_error() on failure. If the ciphertext, mac, or
* ephemeral_key buffers were too small then olm_pk_encryption_last_error()
* will be "OUTPUT_BUFFER_TOO_SMALL". If there weren't enough random bytes then
- * olm_pk_encryption_last_error() will be "NOT_ENOUGH_RANDOM". */
+ * olm_pk_encryption_last_error() will be "OLM_INPUT_BUFFER_TOO_SMALL". */
size_t olm_pk_encrypt(
OlmPkEncryption *encryption,
void const * plaintext, size_t plaintext_length,
@@ -112,19 +112,36 @@ size_t olm_clear_pk_decryption(
OlmPkDecryption *decryption
);
-/** The number of random bytes needed to generate a new key. */
+/** Get the number of bytes required to store an olm private key
+ */
+size_t olm_pk_private_key_length();
+
+/** DEPRECATED: Use olm_pk_private_key_length()
+ */
size_t olm_pk_generate_key_random_length(void);
-/** Generate a new key pair to use for decrypting messages. The private key is
- * stored in the decryption object, and the associated public key will be
- * written to the pubkey buffer. Returns olm_error() on failure. If the pubkey
- * buffer is too small then olm_pk_decryption_last_error() will be
- * "OUTPUT_BUFFER_TOO_SMALL". If there weren't enough random bytes then
- * olm_pk_decryption_last_error() will be "NOT_ENOUGH_RANDOM". */
+/** Initialise the key from the private part of a key as returned by
+ * olm_pk_get_private_key(). The associated public key will be written to the
+ * pubkey buffer. Returns olm_error() on failure. If the pubkey buffer is too
+ * small then olm_pk_decryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
+ * If the private key was not long enough then olm_pk_decryption_last_error()
+ * will be "OLM_INPUT_BUFFER_TOO_SMALL".
+ *
+ * Note that the pubkey is a base64 encoded string, but the private key is
+ * an unencoded byte array
+ */
+size_t olm_pk_key_from_private(
+ OlmPkDecryption * decryption,
+ void * pubkey, size_t pubkey_length,
+ void * privkey, size_t privkey_length
+);
+
+/** DEPRECATED: Use olm_pk_key_from_private
+ */
size_t olm_pk_generate_key(
OlmPkDecryption * decryption,
void * pubkey, size_t pubkey_length,
- void * random, size_t random_length
+ void * privkey, size_t privkey_length
);
/** Returns the number of bytes needed to store a decryption object. */
@@ -177,6 +194,19 @@ size_t olm_pk_decrypt(
void * plaintext, size_t max_plaintext_length
);
+/**
+ * Get the private key for an OlmDecryption object as an unencoded byte array
+ * private_key must be a pointer to a buffer of at least
+ * olm_pk_private_key_length() bytes and this length must be passed in
+ * private_key_length. If the given buffer is too small, returns olm_error()
+ * and olm_pk_encryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
+ * Returns the number of bytes written.
+ */
+size_t olm_pk_get_private_key(
+ OlmPkDecryption * decryption,
+ void *private_key, size_t private_key_length
+);
+
#ifdef __cplusplus
}
#endif