separating ECC crypto into functions/structs for ECDHE, ECDSA and EDDSA
[oweals/gnunet.git] / src / fs / fs_api.h
index 12d4ae44b43f9de8b94777478d60e75d7a8e0f5b..4b0965f150f7a224e39f35388a3935e80a97e36e 100644 (file)
 #include "block_fs.h"
 #include "fs.h"
 
-/**
- * Size of the individual blocks used for file-sharing.
- */
-#define DBLOCK_SIZE (32*1024)
-
 /**
  * Pick a multiple of 2 here to achive 8-byte alignment!  We also
  * probably want DBlocks to have (roughly) the same size as IBlocks.
@@ -125,7 +120,7 @@ struct Location
   /**
    * Identity of the peer sharing the file.
    */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
+  struct GNUNET_PeerIdentity peer;
 
   /**
    * Time when this location URI expires.
@@ -133,39 +128,40 @@ struct Location
   struct GNUNET_TIME_Absolute expirationTime;
 
   /**
-   * RSA signature over the GNUNET_EC_FileIdentifier,
-   * GNUNET_hash of the peer and expiration time.
+   * Signature over the GNUNET_EC_FileIdentifier,
+   * peer identity and expiration time.
    */
-  struct GNUNET_CRYPTO_RsaSignature contentSignature;
+  struct GNUNET_CRYPTO_EddsaSignature contentSignature;
 
 };
 
 /**
  * Types of URIs.
  */
-enum uri_types
+enum GNUNET_FS_UriType
 {
-    /**
-     * Content-hash-key (simple file).
-     */
-  chk,
+  /**
+   * Content-hash-key (simple file).
+   */
+  GNUNET_FS_URI_CHK,
 
-    /**
-     * Signed key space (file in namespace).
-     */
-  sks,
+  /**
+   * Signed key space (file in namespace).
+   */
+  GNUNET_FS_URI_SKS,
 
-    /**
-     * Keyword search key (query with keywords).
-     */
-  ksk,
+  /**
+   * Keyword search key (query with keywords).
+   */
+  GNUNET_FS_URI_KSK,
 
-    /**
-     * Location (chk with identity of hosting peer).
-     */
-  loc
+  /**
+   * Location (chk with identity of hosting peer).
+   */
+  GNUNET_FS_URI_LOC
 };
 
+
 /**
  * A Universal Resource Identifier (URI), opaque.
  */
@@ -174,23 +170,20 @@ struct GNUNET_FS_Uri
   /**
    * Type of the URI.
    */
-  enum uri_types type;
+  enum GNUNET_FS_UriType type;
 
   union
   {
     struct
     {
       /**
-       * Keywords start with a '+' if they are
-       * mandatory (in which case the '+' is NOT
-       * part of the keyword) and with a
-       * simple space if they are optional
-       * (in which case the space is ALSO not
-       * part of the actual keyword).
+       * Keywords start with a '+' if they are mandatory (in which
+       * case the '+' is NOT part of the keyword) and with a simple
+       * space if they are optional (in which case the space is ALSO
+       * not part of the actual keyword).
        *
-       * Double-quotes to protect spaces and
-       * %-encoding are NOT used internally
-       * (only in URI-strings).
+       * Double-quotes to protect spaces and %-encoding are NOT used
+       * internally (only in URI-strings).
        */
       char **keywords;
 
@@ -203,15 +196,16 @@ struct GNUNET_FS_Uri
     struct
     {
       /**
-       * Hash of the public key for the namespace.
+       * Identifier of the namespace.
        */
-      struct GNUNET_HashCode ns;
+      struct GNUNET_CRYPTO_EcdsaPublicKey ns;
 
       /**
-       * Human-readable identifier chosen for this
-       * entry in the namespace.
+       * Human-readable identifier chosen for this entry in the
+       * namespace.
        */
       char *identifier;
+
     } sks;
 
     /**
@@ -346,7 +340,7 @@ struct GNUNET_FS_FileInformation
       int do_index;
 
       /**
-       * Is "file_id" already valid?  Set to GNUNET_YES once the hash
+       * Is "file_id" already valid?  Set to #GNUNET_YES once the hash
        * has been calculated.
        */
       int have_hash;
@@ -420,7 +414,7 @@ typedef void (*GNUNET_FS_QueueStop) (void *cls);
 
 /**
  * Priorities for the queue.
- */ 
+ */
 enum GNUNET_FS_QueuePriority
   {
     /**
@@ -509,8 +503,6 @@ struct GNUNET_FS_QueueEntry
 };
 
 
-
-
 /**
  * Information we store for each search result.
  */
@@ -518,7 +510,13 @@ struct GNUNET_FS_SearchResult
 {
 
   /**
-   * Search context this result belongs to.
+   * File-sharing context this result belongs to.
+   */
+  struct GNUNET_FS_Handle *h;
+
+  /**
+   * Search context this result belongs to; can be NULL
+   * for probes that come from a directory result.
    */
   struct GNUNET_FS_SearchContext *sc;
 
@@ -593,6 +591,11 @@ struct GNUNET_FS_SearchResult
    */
   struct GNUNET_TIME_Relative remaining_probe_time;
 
+  /**
+   * Anonymity level to use for probes using this search result.
+   */
+  uint32_t anonymity;
+
   /**
    * Number of mandatory keywords for which we have NOT yet found the
    * search result; when this value hits zero, the search result is
@@ -818,11 +821,13 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
  * call the callback.
  *
  * @param pi structure to fill in
+ * @param h file-sharing handle
  * @param sc overall search context
  * @return value returned by the callback
  */
 void *
 GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
+                              struct GNUNET_FS_Handle *h,
                                struct GNUNET_FS_SearchContext *sc);
 
 
@@ -1166,7 +1171,7 @@ struct GNUNET_FS_PublishContext
   /**
    * Namespace that we are publishing in, NULL if we have no namespace.
    */
-  struct GNUNET_FS_Namespace *ns;
+  struct GNUNET_CRYPTO_EcdsaPrivateKey *ns;
 
   /**
    * ID of the content in the namespace, NULL if we have no namespace.
@@ -1254,7 +1259,7 @@ struct GNUNET_FS_PublishContext
    * Set to GNUNET_YES if all processing has completed.
    */
   int all_done;
-  
+
   /**
    * Flag set to GNUNET_YES if the next callback from
    * GNUNET_FS_file_information_inspect should be skipped because it
@@ -1279,7 +1284,7 @@ enum UnindexState
    * the respective DBlocks and IBlocks.
    */
   UNINDEX_STATE_DS_REMOVE = 1,
-  
+
   /**
    * Find out which keywords apply.
    */
@@ -1295,12 +1300,12 @@ enum UnindexState
    * the unindexing.
    */
   UNINDEX_STATE_FS_NOTIFY = 4,
-  
+
   /**
    * We're done.
    */
   UNINDEX_STATE_COMPLETE = 5,
-  
+
   /**
    * We've encountered a fatal error.
    */
@@ -1318,7 +1323,7 @@ struct GNUNET_FS_UnindexContext
    * The content hash key of the last block we processed, will in the
    * end be set to the CHK from the URI.  Used to remove the KBlocks.
    */
-  struct ContentHashKey chk; 
+  struct ContentHashKey chk;
 
   /**
    * Global FS context.
@@ -1389,14 +1394,14 @@ struct GNUNET_FS_UnindexContext
   struct GNUNET_DATASTORE_QueueEntry *dqe;
 
   /**
-   * Current key for decrypting KBLocks from 'get_key' operation.
+   * Current key for decrypting UBLocks from 'get_key' operation.
    */
-  struct GNUNET_HashCode key;
+  struct GNUNET_HashCode ukey;
 
   /**
    * Current query of 'get_key' operation.
    */
-  struct GNUNET_HashCode query;
+  struct GNUNET_HashCode uquery;
 
   /**
    * First content UID, 0 for none.
@@ -1447,16 +1452,22 @@ struct GNUNET_FS_UnindexContext
  */
 struct SearchRequestEntry
 {
+
   /**
-   * Hash of the original keyword, also known as the
-   * key (for decrypting the KBlock).
+   * Hash of the public key, also known as the query.
    */
-  struct GNUNET_HashCode key;
+  struct GNUNET_HashCode uquery;
 
   /**
-   * Hash of the public key, also known as the query.
+   * Derived public key, hashes to 'uquery'.
+   */
+  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
+
+  /**
+   * The original keyword, used to derive the
+   * key (for decrypting the UBlock).
    */
-  struct GNUNET_HashCode query;
+  char *keyword;
 
   /**
    * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
@@ -1951,96 +1962,6 @@ struct GNUNET_FS_DownloadContext
 };
 
 
-/**
- * Information about an (updateable) node in the
- * namespace.
- */
-struct NamespaceUpdateNode
-{
-  /**
-   * Identifier for this node.
-   */
-  char *id;
-
-  /**
-   * Identifier of children of this node.
-   */
-  char *update;
-
-  /**
-   * Metadata for this entry.
-   */
-  struct GNUNET_CONTAINER_MetaData *md;
-
-  /**
-   * URI of this entry in the namespace.
-   */
-  struct GNUNET_FS_Uri *uri;
-
-  /**
-   * Namespace update generation ID.  Used to ensure
-   * freshness of the tree_id.
-   */
-  unsigned int nug;
-
-  /**
-   * TREE this entry belongs to (if nug is current).
-   */
-  unsigned int tree_id;
-
-};
-
-
-struct GNUNET_FS_Namespace
-{
-
-  /**
-   * Handle to the FS service context.
-   */
-  struct GNUNET_FS_Handle *h;
-
-  /**
-   * Array with information about nodes in the namespace.
-   */
-  struct NamespaceUpdateNode **update_nodes;
-
-  /**
-   * Private key for the namespace.
-   */
-  struct GNUNET_CRYPTO_RsaPrivateKey *key;
-
-  /**
-   * Hash map mapping identifiers of update nodes
-   * to the update nodes (initialized on-demand).
-   */
-  struct GNUNET_CONTAINER_MultiHashMap *update_map;
-
-  /**
-   * Name of the file with the private key.
-   */
-  char *filename;
-
-  /**
-   * Name of the namespace.
-   */
-  char *name;
-
-  /**
-   * Size of the update nodes array.
-   */
-  unsigned int update_node_count;
-
-  /**
-   * Reference counter.
-   */
-  unsigned int rc;
-
-  /**
-   * Generator for unique nug numbers.
-   */
-  unsigned int nug_gen;
-};
-
 #endif
 
 /* end of fs_api.h */