2 This file is part of GNUnet.
3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_crypto_lib.h
23 * @brief cryptographic primitives for GNUnet
25 * @author Christian Grothoff
26 * @author Krista Bennett
27 * @author Gerd Knorr <kraxel@bytesex.org>
28 * @author Ioana Patrascu
29 * @author Tzvetan Horozov
31 * @defgroup crypto Cryptographic operations
32 * @defgroup hash Hashing and operations on hashes
35 #ifndef GNUNET_CRYPTO_LIB_H
36 #define GNUNET_CRYPTO_LIB_H
41 #if 0 /* keep Emacsens' auto-indent happy */
46 #include "gnunet_common.h"
47 #include "gnunet_scheduler_lib.h"
51 * Maximum length of an ECC signature.
52 * Note: round up to multiple of 8 minus 2 for alignment.
54 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
58 * Desired quality level for random numbers.
61 enum GNUNET_CRYPTO_Quality
64 * No good quality of the operation is needed (i.e.,
65 * random numbers can be pseudo-random).
68 GNUNET_CRYPTO_QUALITY_WEAK,
71 * High-quality operations are desired.
74 GNUNET_CRYPTO_QUALITY_STRONG,
77 * Randomness for IVs etc. is required.
80 GNUNET_CRYPTO_QUALITY_NONCE
85 * @brief length of the sessionkey in bytes (256 BIT sessionkey)
87 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8)
90 * Length of a hash value
92 #define GNUNET_CRYPTO_HASH_LENGTH (512/8)
95 * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode.
97 struct GNUNET_CRYPTO_HashAsciiEncoded
99 unsigned char encoding[104];
103 GNUNET_NETWORK_STRUCT_BEGIN
107 * @brief header of what an ECC signature signs
108 * this must be followed by "size - 8" bytes of
109 * the actual signed data
111 struct GNUNET_CRYPTO_EccSignaturePurpose
114 * How many bytes does this signature sign?
115 * (including this purpose header); in network
118 uint32_t size GNUNET_PACKED;
121 * What does this signature vouch for? This
122 * must contain a GNUNET_SIGNATURE_PURPOSE_XXX
123 * constant (from gnunet_signatures.h). In
124 * network byte order!
126 uint32_t purpose GNUNET_PACKED;
132 * @brief an ECC signature
134 struct GNUNET_CRYPTO_EccSignature
140 unsigned char r[256 / 8];
145 unsigned char s[256 / 8];
151 * Public ECC key (always for NIST P-521) encoded in a format suitable
152 * for network transmission.
154 struct GNUNET_CRYPTO_EccPublicKey
157 * Q consists of an x- and a y-value, each mod p (256 bits),
158 * given here in affine coordinates.
160 unsigned char q_x[256 / 8];
163 * Q consists of an x- and a y-value, each mod p (256 bits),
164 * given here in affine coordinates.
166 unsigned char q_y[256 / 8];
172 * Private ECC key encoded for transmission.
174 struct GNUNET_CRYPTO_EccPrivateKey
177 * d is a value mod n, where n has at most 256 bits.
179 unsigned char d[256 / 8];
185 * @brief type for session keys
187 struct GNUNET_CRYPTO_AesSessionKey
192 unsigned char key[GNUNET_CRYPTO_AES_KEY_LENGTH];
195 GNUNET_NETWORK_STRUCT_END
198 * @brief IV for sym cipher
200 * NOTE: must be smaller (!) in size than the
201 * struct GNUNET_HashCode.
203 struct GNUNET_CRYPTO_AesInitializationVector
205 unsigned char iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
210 * @brief type for (message) authentication keys
212 struct GNUNET_CRYPTO_AuthKey
214 unsigned char key[GNUNET_CRYPTO_HASH_LENGTH];
218 /* **************** Functions and Macros ************* */
222 * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode generator
225 * @param seed the seed to use
228 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
232 * Perform an incremental step in a CRC16 (for TCP/IP) calculation.
234 * @param sum current sum, initially 0
235 * @param buf buffer to calculate CRC over (must be 16-bit aligned)
236 * @param len number of bytes in @a buf, must be multiple of 2
237 * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16)
240 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
244 * Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
246 * @param sum cummulative sum
247 * @return crc16 value
250 GNUNET_CRYPTO_crc16_finish (uint32_t sum);
255 * Calculate the checksum of a buffer in one step.
257 * @param buf buffer to calculate CRC over (must be 16-bit aligned)
258 * @param len number of bytes in @a buf, must be multiple of 2
259 * @return crc16 value
262 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
267 * Compute the CRC32 checksum for the first len
268 * bytes of the buffer.
270 * @param buf the data over which we're taking the CRC
271 * @param len the length of the buffer @a buf in bytes
272 * @return the resulting CRC32 checksum
275 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
280 * Produce a random value.
282 * @param mode desired quality of the random number
283 * @param i the upper limit (exclusive) for the random number
284 * @return a random value in the interval [0,@a i) (exclusive).
287 GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i);
292 * Random on unsigned 64-bit values.
294 * @param mode desired quality of the random number
295 * @param max value returned will be in range [0,@a max) (exclusive)
296 * @return random 64-bit number
299 GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max);
304 * Get an array with a random permutation of the
306 * @param mode #GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive) PRNG should be used,
307 * #GNUNET_CRYPTO_QUALITY_WEAK or #GNUNET_CRYPTO_QUALITY_NONCE otherwise
308 * @param n the size of the array
309 * @return the permutation array (allocated from heap)
312 GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n);
317 * Create a new random session key.
319 * @param key key to initialize
322 GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey *key);
327 * Encrypt a block using a symmetric sessionkey.
329 * @param block the block to encrypt
330 * @param len the size of the block
331 * @param sessionkey the key used to encrypt
332 * @param iv the initialization vector to use, use INITVALUE
334 * @return the size of the encrypted block, -1 for errors
337 GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len,
338 const struct GNUNET_CRYPTO_AesSessionKey *sessionkey,
339 const struct GNUNET_CRYPTO_AesInitializationVector
345 * Decrypt a given block using a symmetric sessionkey.
347 * @param block the data to decrypt, encoded as returned by encrypt
348 * @param size how big is the block?
349 * @param sessionkey the key used to decrypt
350 * @param iv the initialization vector to use
351 * @param result address to store the result at
352 * @return -1 on failure, size of decrypted block on success
355 GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size,
356 const struct GNUNET_CRYPTO_AesSessionKey *sessionkey,
357 const struct GNUNET_CRYPTO_AesInitializationVector
363 * @brief Derive an IV
364 * @param iv initialization vector
365 * @param skey session key
366 * @param salt salt for the derivation
367 * @param salt_len size of the salt
368 * @param ... pairs of void * & size_t for context chunks, terminated by NULL
371 GNUNET_CRYPTO_aes_derive_iv (struct GNUNET_CRYPTO_AesInitializationVector *iv,
372 const struct GNUNET_CRYPTO_AesSessionKey *skey,
373 const void *salt, size_t salt_len, ...);
377 * @brief Derive an IV
378 * @param iv initialization vector
379 * @param skey session key
380 * @param salt salt for the derivation
381 * @param salt_len size of the salt
382 * @param argp pairs of void * & size_t for context chunks, terminated by NULL
385 GNUNET_CRYPTO_aes_derive_iv_v (struct GNUNET_CRYPTO_AesInitializationVector *iv,
386 const struct GNUNET_CRYPTO_AesSessionKey *skey,
387 const void *salt, size_t salt_len, va_list argp);
392 * Convert hash to ASCII encoding.
393 * @param block the hash code
394 * @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be
395 * safely cast to char*, a '\\0' termination is set).
398 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block,
399 struct GNUNET_CRYPTO_HashAsciiEncoded *result);
404 * Convert ASCII encoding back to a 'struct GNUNET_HashCode'
406 * @param enc the encoding
407 * @param enclen number of characters in @a enc (without 0-terminator, which can be missing)
408 * @param result where to store the hash code
409 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding
412 GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
413 struct GNUNET_HashCode *result);
418 * Convert ASCII encoding back to struct GNUNET_HashCode
420 * @param enc the encoding
421 * @param result where to store the hash code
422 * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
424 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
425 GNUNET_CRYPTO_hash_from_string2 (enc, strlen(enc), result)
430 * Compute the distance between 2 hashcodes.
431 * The computation must be fast, not involve
432 * a.a or a.e (they're used elsewhere), and
433 * be somewhat consistent. And of course, the
434 * result should be a positive number.
436 * @param a some hash code
437 * @param b some hash code
438 * @return number between 0 and UINT32_MAX
441 GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode * a,
442 const struct GNUNET_HashCode * b);
447 * Compute hash of a given block.
449 * @param block the data to hash
450 * @param size size of the @a block
451 * @param ret pointer to where to write the hashcode
454 GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode * ret);
459 * Calculate HMAC of a message (RFC 2104)
461 * @param key secret key
462 * @param plaintext input plaintext
463 * @param plaintext_len length of @a plaintext
464 * @param hmac where to store the hmac
467 GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
468 const void *plaintext, size_t plaintext_len,
469 struct GNUNET_HashCode * hmac);
473 * Function called once the hash computation over the
474 * specified file has completed.
477 * @param res resulting hash, NULL on error
479 typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
480 const struct GNUNET_HashCode *
485 * Handle to file hashing operation.
487 struct GNUNET_CRYPTO_FileHashContext;
492 * Compute the hash of an entire file.
494 * @param priority scheduling priority to use
495 * @param filename name of file to hash
496 * @param blocksize number of bytes to process in one task
497 * @param callback function to call upon completion
498 * @param callback_cls closure for callback
499 * @return NULL on (immediate) errror
501 struct GNUNET_CRYPTO_FileHashContext *
502 GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
503 const char *filename, size_t blocksize,
504 GNUNET_CRYPTO_HashCompletedCallback callback,
509 * Cancel a file hashing operation.
511 * @param fhc operation to cancel (callback must not yet have been invoked)
514 GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc);
519 * Create a random hash code.
521 * @param mode desired quality level
522 * @param result hash code that is randomized
525 GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
526 struct GNUNET_HashCode * result);
531 * compute result(delta) = b - a
533 * @param a some hash code
534 * @param b some hash code
535 * @param result set to @a b - @a a
538 GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode * a,
539 const struct GNUNET_HashCode * b,
540 struct GNUNET_HashCode * result);
545 * compute result(b) = a + delta
547 * @param a some hash code
548 * @param delta some hash code
549 * @param result set to @a a + @a delta
552 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode * a,
553 const struct GNUNET_HashCode * delta,
554 struct GNUNET_HashCode * result);
559 * compute result = a ^ b
561 * @param a some hash code
562 * @param b some hash code
563 * @param result set to @a a ^ @a b
566 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode * a, const struct GNUNET_HashCode * b,
567 struct GNUNET_HashCode * result);
572 * Convert a hashcode into a key.
574 * @param hc hash code that serves to generate the key
575 * @param skey set to a valid session key
576 * @param iv set to a valid initialization vector
579 GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc,
580 struct GNUNET_CRYPTO_AesSessionKey *skey,
581 struct GNUNET_CRYPTO_AesInitializationVector
587 * Obtain a bit from a hashcode.
589 * @param code the GNUNET_CRYPTO_hash to index bit-wise
590 * @param bit index into the hashcode, [0...159]
591 * @return Bit \a bit from hashcode \a code, -1 for invalid index
594 GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode * code, unsigned int bit);
599 * Determine how many low order bits match in two
600 * struct GNUNET_HashCodes. i.e. - 010011 and 011111 share
601 * the first two lowest order bits, and therefore the
602 * return value is two (NOT XOR distance, nor how many
603 * bits match absolutely!).
605 * @param first the first hashcode
606 * @param second the hashcode to compare first to
607 * @return the number of bits that match
610 GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode * first,
611 const struct GNUNET_HashCode * second);
616 * Compare function for HashCodes, producing a total ordering
619 * @param h1 some hash code
620 * @param h2 some hash code
621 * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
624 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode * h1, const struct GNUNET_HashCode * h2);
629 * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target
630 * in the XOR metric (Kademlia).
632 * @param h1 some hash code
633 * @param h2 some hash code
634 * @param target some hash code
635 * @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
638 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode * h1,
639 const struct GNUNET_HashCode * h2,
640 const struct GNUNET_HashCode * target);
645 * @brief Derive an authentication key
646 * @param key authentication key
647 * @param rkey root key
649 * @param salt_len size of the salt
650 * @param argp pair of void * & size_t for context chunks, terminated by NULL
653 GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
654 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
655 const void *salt, size_t salt_len,
661 * @brief Derive an authentication key
662 * @param key authentication key
663 * @param rkey root key
665 * @param salt_len size of the salt
666 * @param ... pair of void * & size_t for context chunks, terminated by NULL
669 GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
670 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
671 const void *salt, size_t salt_len, ...);
677 * @param result buffer for the derived key, allocated by caller
678 * @param out_len desired length of the derived key
679 * @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_...
680 * @param prf_algo hash algorithm for the expansion phase, GCRY_MD_...
682 * @param xts_len length of xts
683 * @param skm source key material
684 * @param skm_len length of skm
685 * @param ... pair of void * & size_t for context chunks, terminated by NULL
686 * @return GNUNET_YES on success
689 GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo,
690 const void *xts, size_t xts_len, const void *skm,
691 size_t skm_len, ...);
697 * @param result buffer for the derived key, allocated by caller
698 * @param out_len desired length of the derived key
699 * @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_...
700 * @param prf_algo hash algorithm for the expansion phase, GCRY_MD_...
702 * @param xts_len length of xts
703 * @param skm source key material
704 * @param skm_len length of skm
705 * @param argp va_list of void * & size_t pairs for context chunks
706 * @return GNUNET_YES on success
709 GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo,
710 const void *xts, size_t xts_len, const void *skm,
711 size_t skm_len, va_list argp);
716 * @param result buffer for the derived key, allocated by caller
717 * @param out_len desired length of the derived key
719 * @param xts_len length of xts
720 * @param skm source key material
721 * @param skm_len length of skm
722 * @param argp va_list of void * & size_t pairs for context chunks
723 * @return GNUNET_YES on success
726 GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts,
727 size_t xts_len, const void *skm, size_t skm_len,
734 * @param result buffer for the derived key, allocated by caller
735 * @param out_len desired length of the derived key
737 * @param xts_len length of xts
738 * @param skm source key material
739 * @param skm_len length of skm
740 * @param ... void * & size_t pairs for context chunks
741 * @return GNUNET_YES on success
744 GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts,
745 size_t xts_len, const void *skm, size_t skm_len, ...);
749 * Function called upon completion of 'GNUNET_CRYPTO_ecc_key_create_async'.
752 * @param pk NULL on error, otherwise the private key (which must be free'd by the callee)
753 * @param emsg NULL on success, otherwise an error message
755 typedef void (*GNUNET_CRYPTO_EccKeyCallback)(void *cls,
756 struct GNUNET_CRYPTO_EccPrivateKey *pk,
762 * Free memory occupied by ECC key
764 * @param priv pointer to the memory to free
767 GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *priv);
772 * Extract the public key for the given private key.
774 * @param priv the private key
775 * @param pub where to write the public key
778 GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
779 struct GNUNET_CRYPTO_EccPublicKey *pub);
783 * Convert a public key to a string.
785 * @param pub key to convert
786 * @return string representing 'pub'
789 GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKey *pub);
793 * Convert a string representing a public key to a public key.
795 * @param enc encoded public key
796 * @param enclen number of bytes in enc (without 0-terminator)
797 * @param pub where to store the public key
798 * @return GNUNET_OK on success
801 GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
803 struct GNUNET_CRYPTO_EccPublicKey *pub);
808 * Create a new private key by reading it from a file. If the
809 * files does not exist, create a new key and write it to the
810 * file. Caller must free return value. Note that this function
811 * can not guarantee that another process might not be trying
812 * the same operation on the same file at the same time.
813 * If the contents of the file
814 * are invalid the old file is deleted and a fresh key is
817 * @param filename name of file to use to store the key
818 * @return new private key, NULL on error (for example,
821 struct GNUNET_CRYPTO_EccPrivateKey *
822 GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename);
827 * Create a new private key by reading our peer's key from
828 * the file specified in the configuration.
830 * @return new private key, NULL on error (for example,
833 struct GNUNET_CRYPTO_EccPrivateKey *
834 GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg);
839 * Create a new private key. Caller must free return value.
841 * @return fresh private key
843 struct GNUNET_CRYPTO_EccPrivateKey *
844 GNUNET_CRYPTO_ecc_key_create (void);
849 * Get the shared private key we use for anonymous users.
851 * @return "anonymous" private key
853 const struct GNUNET_CRYPTO_EccPrivateKey *
854 GNUNET_CRYPTO_ecc_key_get_anonymous (void);
859 * Setup a hostkey file for a peer given the name of the
860 * configuration file (!). This function is used so that
861 * at a later point code can be certain that reading a
862 * hostkey is fast (for example in time-dependent testcases).
864 * @param cfg_name name of the configuration file to use
867 GNUNET_CRYPTO_ecc_setup_hostkey (const char *cfg_name);
872 * Retrieve the identity of the host's peer.
874 * @param cfg configuration to use
875 * @param dst pointer to where to write the peer identity
876 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity
877 * could not be retrieved
880 GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
881 struct GNUNET_PeerIdentity *dst);
886 * Derive key material from a public and a private ECC key.
888 * @param priv private key to use for the ECDH (x)
889 * @param pub public key to use for the ECDY (yG)
890 * @param key_material where to write the key material (xyG)
891 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
894 GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
895 const struct GNUNET_CRYPTO_EccPublicKey *pub,
896 struct GNUNET_HashCode *key_material);
901 * Sign a given block.
903 * @param priv private key to use for the signing
904 * @param purpose what to sign (size, purpose)
905 * @param sig where to write the signature
906 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
909 GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
910 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
911 struct GNUNET_CRYPTO_EccSignature *sig);
918 * @param purpose what is the purpose that the signature should have?
919 * @param validate block to validate (size, purpose, data)
920 * @param sig signature that is being validated
921 * @param pub public key of the signer
922 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
925 GNUNET_CRYPTO_ecc_verify (uint32_t purpose,
926 const struct GNUNET_CRYPTO_EccSignaturePurpose
928 const struct GNUNET_CRYPTO_EccSignature *sig,
929 const struct GNUNET_CRYPTO_EccPublicKey *pub);
934 * Derive a private key from a given private key and a label.
935 * Essentially calculates a private key 'h = H(l,P) * d mod n'
936 * where n is the size of the ECC group and P is the public
937 * key associated with the private key 'd'.
939 * @param priv original private key
940 * @param label label to use for key deriviation
941 * @param context additional context to use for HKDF of 'h';
942 * typically the name of the subsystem/application
943 * @return derived private key
945 struct GNUNET_CRYPTO_EccPrivateKey *
946 GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
948 const char *context);
953 * Derive a public key from a given public key and a label.
954 * Essentially calculates a public key 'V = H(l,P) * P'.
956 * @param pub original public key
957 * @param label label to use for key deriviation
958 * @param context additional context to use for HKDF of 'h'.
959 * typically the name of the subsystem/application
960 * @param result where to write the derived public key
963 GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey *pub,
966 struct GNUNET_CRYPTO_EccPublicKey *result);
969 #if 0 /* keep Emacsens' auto-indent happy */
977 /* ifndef GNUNET_CRYPTO_LIB_H */
979 /* end of gnunet_crypto_lib.h */