aboutsummaryrefslogtreecommitdiff
path: root/include/olm/pk.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/olm/pk.h')
-rw-r--r--include/olm/pk.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/include/olm/pk.h b/include/olm/pk.h
index 8804d1f..8748506 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,24 @@ size_t olm_clear_pk_decryption(
OlmPkDecryption *decryption
);
-/** The number of random bytes needed to generate a new key. */
-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". */
-size_t olm_pk_generate_key(
+/** Get the number of bytes required to store an olm private key
+ */
+size_t olm_pk_private_key_length();
+
+/** 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 * random, size_t random_length
+ void * privkey, size_t privkey_length
);
/** Returns the number of bytes needed to store a decryption object. */
@@ -177,6 +182,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