Class KeyRandomArt
java.lang.Object
org.apache.sshd.common.config.keys.KeyRandomArt
- All Implemented Interfaces:
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)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKeyRandomArt
(String algorithm, int keySize, byte[] digest) KeyRandomArt
(PublicKey key) KeyRandomArt
(PublicKey key, Digest d) KeyRandomArt
(PublicKey key, Factory<? extends Digest> f) -
Method Summary
Modifier and TypeMethodDescription<A extends Appendable>
Aappend
(A sb) Outputs the generated random artstatic String
combine
(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 String
combine
(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 providerint
toString()
-
Field Details
-
FLDBASE
public static final int FLDBASE- See Also:
-
FLDSIZE_Y
public static final int FLDSIZE_Y- See Also:
-
FLDSIZE_X
public static final int FLDSIZE_X- See Also:
-
AUGMENTATION_STRING
- See Also:
-
algorithm
-
keySize
private final int keySize -
field
private final char[][] field
-
-
Constructor Details
-
Method Details
-
getAlgorithm
- Specified by:
getAlgorithm
in interfaceAlgorithmNameProvider
- Returns:
- The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".
-
getKeySize
public int getKeySize()- Specified by:
getKeySize
in interfaceKeySizeIndicator
- Returns:
- The number of bits used in the key
-
append
Outputs the generated random art- Type Parameters:
A
- TheAppendable
output writer- Parameters:
sb
- The writer- Returns:
- The updated writer instance
- Throws:
IOException
- If failed to write the combined result
-
toString
-
combine
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
- TheKeyRandomArt
s 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
- TheSessionContext
for invoking this load command - may benull
if 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 ifnull
or has no keys to provide- Returns:
- The combined representation
- Throws:
Exception
- If failed to extract or combine the entries- See Also:
-
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
- TheAppendable
output writer- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if 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 ifnull
or has no keys to provide- Returns:
- The updated writer instance
- Throws:
Exception
- If failed to extract or write the entries- See Also:
-
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
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).provider
- TheKeyIdentityProvider
- ignored ifnull
or has no keys to provide- Returns:
- The extracted
KeyRandomArt
s - Throws:
Exception
- If failed to extract the entries- See Also:
-
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
- TheAppendable
output writer- Parameters:
sb
- The writerseparator
- The separator to use between the arts - if empty char ('\0') then no separation is donearts
- TheKeyRandomArt
s to combine - ignored ifnull
/empty- Returns:
- The updated writer instance
- Throws:
IOException
- If failed to write the combined result
-