net.i2p.router.crypto

## Class FamilyKeyCrypto

- java.lang.Object
- - net.i2p.router.crypto.FamilyKeyCrypto

-     public class FamilyKeyCrypto
      extends Object

  Utilities for creating, storing, retrieving the signing keys for the netdb family feature

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FamilyKeyCrypto.Result` Only STORED_KEY is fully trusted.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CERT_SUFFIX`
    `static String` | `CN_SUFFIX`
    `static String` | `CRL_SUFFIX`
    `static String` | `KEYSTORE_PREFIX`
    `static String` | `KEYSTORE_SUFFIX`
    `static String` | `OPT_KEY`
    `static String` | `OPT_NAME`
    `static String` | `OPT_SIG`
    `static String` | `PROP_FAMILY_NAME`
    `static String` | `PROP_KEY_PASSWORD`
    `static String` | `PROP_KEYSTORE_PASSWORD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FamilyKeyCrypto(RouterContext context)` For signing and verification.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<Hash>` | `getOurFamily()` Get verified members of our family.
    `String` | `getOurFamilyName()` Get our family name.
    `boolean` | `hasFamily()` Do we have a valid family?
    `static void` | `main(String[] args)`
    `void` | `shutdown()` Clears the caches
    `Map<String,String>` | `sign(String family, Hash h)` Caller must add family to RI also.
    `FamilyKeyCrypto.Result` | `verify(RouterInfo ri)` Verify the family signature in a RouterInfo.
    `boolean` | `verifyOurFamily(RouterInfo ri)` Verify the family in a RouterInfo matches ours and the signature is good.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CERT_SUFFIX

          public static final String CERT_SUFFIX

      See Also:
        Constant Field Values

    - #### CN_SUFFIX

          public static final String CN_SUFFIX

      See Also:
        Constant Field Values

    - #### CRL_SUFFIX

          public static final String CRL_SUFFIX

      See Also:
        Constant Field Values

    - #### KEYSTORE_PREFIX

          public static final String KEYSTORE_PREFIX

      See Also:
        Constant Field Values

    - #### KEYSTORE_SUFFIX

          public static final String KEYSTORE_SUFFIX

      See Also:
        Constant Field Values

    - #### OPT_KEY

          public static final String OPT_KEY

      See Also:
        Constant Field Values

    - #### OPT_NAME

          public static final String OPT_NAME

      See Also:
        Constant Field Values

    - #### OPT_SIG

          public static final String OPT_SIG

      See Also:
        Constant Field Values

    - #### PROP_FAMILY_NAME

          public static final String PROP_FAMILY_NAME

      See Also:
        Constant Field Values

    - #### PROP_KEY_PASSWORD

          public static final String PROP_KEY_PASSWORD

      See Also:
        Constant Field Values

    - #### PROP_KEYSTORE_PASSWORD

          public static final String PROP_KEYSTORE_PASSWORD

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FamilyKeyCrypto

          public FamilyKeyCrypto(RouterContext context)
                          throws GeneralSecurityException

      For signing and verification. If the context property netdb.family.name is set, this can be used for signing, else only for verification.
      Throws:
        `GeneralSecurityException`

  - ### Method Detail

    - #### getOurFamily

          public Set<Hash> getOurFamily()

      Get verified members of our family. Will not contain ourselves.
      Returns:
        non-null, not a copy, do not modify

    - #### getOurFamilyName

          public String getOurFamilyName()

      Get our family name.
      Returns:
        name or null

    - #### hasFamily

          public boolean hasFamily()

      Do we have a valid family?

    - #### main

          public static void main(String[] args)

    - #### shutdown

          public void shutdown()

      Clears the caches

    - #### sign

          public Map<String,String> sign(String family,
                                         Hash h)
                                  throws GeneralSecurityException

      Caller must add family to RI also. throws on all errors
      Parameters:
        `family` - non-null, must match that we were initialized with or will throw GSE
        `h` - non-null
      Returns:
        non-null options to be added to the RI
      Throws:
        `GeneralSecurityException` - on null hash, null or changed family, or signing error

    - #### verify

          public FamilyKeyCrypto.Result verify(RouterInfo ri)

      Verify the family signature in a RouterInfo. This requires a family key in the RI, or a certificate file for the family in certificates/family.
      Returns:
        Result

    - #### verifyOurFamily

          public boolean verifyOurFamily(RouterInfo ri)

      Verify the family in a RouterInfo matches ours and the signature is good. Returns false if we don't have a family and sig, or they don't. Returns false for ourselves.
      Returns:
        true if family matches with good sig