Package 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- Since:
- 0.9.24
-
-
Field Summary
Fields Modifier and Type Field 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 Description FamilyKeyCrypto(RouterContext context)
For signing and verification.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 cachesMap<String,String>
sign(String family, Hash h)
Caller must add family to RI also.boolean
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.
-
-
-
Field Detail
-
PROP_KEYSTORE_PASSWORD
public static final String PROP_KEYSTORE_PASSWORD
- 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
-
CERT_SUFFIX
public static final String CERT_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
-
CN_SUFFIX
public static final String CN_SUFFIX
- 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
-
OPT_KEY
public static final String OPT_KEY
- 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
-
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 GSEh
- non-null- Returns:
- non-null options to be added to the RI
- Throws:
GeneralSecurityException
- on null hash, null or changed family, or signing error
-
hasFamily
public boolean hasFamily()
Do we have a valid family?- Since:
- 0.9.28
-
getOurFamily
public Set<Hash> getOurFamily()
Get verified members of our family. Will not contain ourselves.- Returns:
- non-null, not a copy, do not modify
- Since:
- 0.9.28
-
getOurFamilyName
public String getOurFamilyName()
Get our family name.- Returns:
- name or null
- Since:
- 0.9.28
-
verify
public boolean verify(RouterInfo ri)
Verify the family signature in a RouterInfo.- Returns:
- true if good sig or if no family specified at all
-
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
- Since:
- 0.9.28
-
main
public static void main(String[] args)
- Since:
- 0.9.36
-
-