Class KeyRandomArt
- java.lang.Object
-
- org.apache.sshd.common.config.keys.KeyRandomArt
-
- All Implemented Interfaces:
AlgorithmNameProvider,KeySizeIndicator
public class KeyRandomArt extends Object implements AlgorithmNameProvider, KeySizeIndicator
Draw an ASCII-Art representing the fingerprint so human brain can profit from its built-in pattern recognition ability. This technique is called "random art" and can be found in some scientific publications like this original paper: "Hash Visualization: a New Technique to improve Real-World Security", Perrig A. and Song D., 1999, International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99)- Author:
- Apache MINA SSHD Project
- See Also:
- Original article, C implementation
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUGMENTATION_STRINGstatic intFLDBASEstatic intFLDSIZE_Xstatic intFLDSIZE_Y
-
Constructor Summary
Constructors Constructor Description KeyRandomArt(String algorithm, int keySize, byte[] digest)KeyRandomArt(PublicKey key)KeyRandomArt(PublicKey key, Digest d)KeyRandomArt(PublicKey key, Factory<? extends Digest> f)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Appendable>
Aappend(A sb)Outputs the generated random artstatic Stringcombine(char separator, Collection<? extends KeyRandomArt> arts)Combines the arts in a user-friendly way so they are aligned with each otherstatic <A extends Appendable>
Acombine(A sb, char separator, Collection<? extends KeyRandomArt> arts)Combines the arts in a user-friendly way so they are aligned with each otherstatic Stringcombine(SessionContext session, char separator, KeyIdentityProvider provider)Creates the combined representation of the random art entries for the provided keysstatic <A extends Appendable>
Acombine(SessionContext session, A sb, char separator, KeyIdentityProvider provider)Appends the combined random art entries for the provided keysstatic Collection<KeyRandomArt>generate(SessionContext session, KeyIdentityProvider provider)Extracts and generates random art entries for all key in the providerStringgetAlgorithm()intgetKeySize()StringtoString()
-
-
-
Field Detail
-
FLDBASE
public static final int FLDBASE
- See Also:
- Constant Field Values
-
FLDSIZE_Y
public static final int FLDSIZE_Y
- See Also:
- Constant Field Values
-
FLDSIZE_X
public static final int FLDSIZE_X
- See Also:
- Constant Field Values
-
AUGMENTATION_STRING
public static final String AUGMENTATION_STRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KeyRandomArt
public KeyRandomArt(PublicKey key, Factory<? extends Digest> f) throws Exception
- Throws:
Exception
-
KeyRandomArt
public KeyRandomArt(String algorithm, int keySize, byte[] digest)
- Parameters:
algorithm- The key algorithmkeySize- The key size in bitsdigest- The key digest
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithmin interfaceAlgorithmNameProvider- Returns:
- The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".
-
getKeySize
public int getKeySize()
- Specified by:
getKeySizein interfaceKeySizeIndicator- Returns:
- The number of bits used in the key
-
append
public <A extends Appendable> A append(A sb) throws IOException
Outputs the generated random art- Type Parameters:
A- TheAppendableoutput writer- Parameters:
sb- The writer- Returns:
- The updated writer instance
- Throws:
IOException- If failed to write the combined result
-
combine
public static String combine(char separator, Collection<? extends KeyRandomArt> arts)
Combines the arts in a user-friendly way so they are aligned with each other- Parameters:
separator- The separator to use between the arts - if empty char ('\0') then no separation is donearts- TheKeyRandomArts to combine - ignored ifnull/empty- Returns:
- The combined result
-
combine
public static String combine(SessionContext session, char separator, KeyIdentityProvider provider) throws Exception
Creates the combined representation of the random art entries for the provided keys- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).separator- The separator to use between the arts - if empty char ('\0') then no separation is doneprovider- TheKeyIdentityProvider- ignored ifnullor has no keys to provide- Returns:
- The combined representation
- Throws:
Exception- If failed to extract or combine the entries- See Also:
combine(SessionContext, Appendable, char, KeyIdentityProvider)
-
combine
public static <A extends Appendable> A combine(SessionContext session, A sb, char separator, KeyIdentityProvider provider) throws Exception
Appends the combined random art entries for the provided keys- Type Parameters:
A- TheAppendableoutput writer- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).sb- The writerseparator- The separator to use between the arts - if empty char ('\0') then no separation is doneprovider- TheKeyIdentityProvider- ignored ifnullor has no keys to provide- Returns:
- The updated writer instance
- Throws:
Exception- If failed to extract or write the entries- See Also:
generate(SessionContext, KeyIdentityProvider),combine(Appendable, char, Collection)
-
generate
public static Collection<KeyRandomArt> generate(SessionContext session, KeyIdentityProvider provider) throws Exception
Extracts and generates random art entries for all key in the provider- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).provider- TheKeyIdentityProvider- ignored ifnullor has no keys to provide- Returns:
- The extracted
KeyRandomArts - Throws:
Exception- If failed to extract the entries- See Also:
KeyIdentityProvider.loadKeys(SessionContext)
-
combine
public static <A extends Appendable> A combine(A sb, char separator, Collection<? extends KeyRandomArt> arts) throws IOException
Combines the arts in a user-friendly way so they are aligned with each other- Type Parameters:
A- TheAppendableoutput writer- Parameters:
sb- The writerseparator- The separator to use between the arts - if empty char ('\0') then no separation is donearts- TheKeyRandomArts to combine - ignored ifnull/empty- Returns:
- The updated writer instance
- Throws:
IOException- If failed to write the combined result
-
-