# SecurityUtils (sshj 0.4.0 API)
Date: 2011-06-06

## net.schmizz.sshj.common
Class SecurityUtils

    java.lang.Object
      net.schmizz.sshj.common.SecurityUtils

    public class SecurityUtils

extends Object

Static utility method relating to security facilities.

Field Summary
`static String` `BOUNCY_CASTLE` Identifier for the BouncyCastle JCE provider

Constructor Summary
`SecurityUtils()`

Method Summary
`static Cipher` `getCipher(String transformation)`
`static String` `getFingerprint(PublicKey key)` Computes the fingerprint for a public key, in the standard SSH format, e.g.
`static KeyAgreement` `getKeyAgreement(String algorithm)` Creates a new instance of `KeyAgreement` with the given algorithm.
`static KeyFactory` `getKeyFactory(String algorithm)` Creates a new instance of `KeyFactory` with the given algorithm.
`static KeyPairGenerator` `getKeyPairGenerator(String algorithm)` Creates a new instance of `KeyPairGenerator` with the given algorithm.
`static Mac` `getMAC(String algorithm)` Create a new instance of `Mac` with the given algorithm.
`static MessageDigest` `getMessageDigest(String algorithm)` Create a new instance of `MessageDigest` with the given algorithm.
`static String` `getSecurityProvider()` Get the identifier for the registered security provider.
`static Signature` `getSignature(String algorithm)`
`static boolean` `isBouncyCastleRegistered()` Attempts registering BouncyCastle as security provider if it has not been previously attempted and returns whether the registration succeeded.
`static void` `setRegisterBouncyCastle(boolean registerBouncyCastle)`
`static void` `setSecurityProvider(String securityProvider)` Specifies the JCE security provider that should be used.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### BOUNCY_CASTLE

    public static final String BOUNCY_CASTLE

  Identifier for the BouncyCastle JCE provider

  See Also:
    Constant Field Values

Constructor Detail

### SecurityUtils

    public SecurityUtils()

Method Detail

### getCipher

    public static Cipher getCipher(String transformation)
                            throws NoSuchAlgorithmException,
                                   NoSuchPaddingException,
                                   NoSuchProviderException

  Throws:
    `NoSuchAlgorithmException`
    `NoSuchPaddingException`
    `NoSuchProviderException`

### getFingerprint

    public static String getFingerprint(PublicKey key)

  Computes the fingerprint for a public key, in the standard SSH format, e.g. "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21"

  Parameters:
    `key` - the public key
  Returns:
    the fingerprint
  See Also:
    specification

### getKeyAgreement

    public static KeyAgreement getKeyAgreement(String algorithm)
                                        throws NoSuchAlgorithmException,
                                               NoSuchProviderException

  Creates a new instance of `KeyAgreement` with the given algorithm.

  Parameters:
    `algorithm` - key agreement algorithm
  Returns:
    new instance
  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### getKeyFactory

    public static KeyFactory getKeyFactory(String algorithm)
                                    throws NoSuchAlgorithmException,
                                           NoSuchProviderException

  Creates a new instance of `KeyFactory` with the given algorithm.

  Parameters:
    `algorithm` - key factory algorithm e.g. RSA, DSA
  Returns:
    new instance
  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### getKeyPairGenerator

    public static KeyPairGenerator getKeyPairGenerator(String algorithm)
                                                throws NoSuchAlgorithmException,
                                                       NoSuchProviderException

  Creates a new instance of `KeyPairGenerator` with the given algorithm.

  Parameters:
    `algorithm` - key pair generator algorithm
  Returns:
    new instance
  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### getMAC

    public static Mac getMAC(String algorithm)
                      throws NoSuchAlgorithmException,
                             NoSuchProviderException

  Create a new instance of `Mac` with the given algorithm.

  Parameters:
    `algorithm` - MAC algorithm
  Returns:
    new instance
  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### getMessageDigest

    public static MessageDigest getMessageDigest(String algorithm)
                                          throws NoSuchAlgorithmException,
                                                 NoSuchProviderException

  Create a new instance of `MessageDigest` with the given algorithm.

  Parameters:
    `algorithm` - MessageDigest algorithm name
  Returns:
    new instance
  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### getSecurityProvider

    public static String getSecurityProvider()

  Get the identifier for the registered security provider.

  Returns:
    JCE provider identifier

### getSignature

    public static Signature getSignature(String algorithm)
                                  throws NoSuchAlgorithmException,
                                         NoSuchProviderException

  Throws:
    `NoSuchAlgorithmException`
    `NoSuchProviderException`

### isBouncyCastleRegistered

    public static boolean isBouncyCastleRegistered()

  Attempts registering BouncyCastle as security provider if it has not been previously attempted and returns whether the registration succeeded.

  Returns:
    whether BC registered

### setRegisterBouncyCastle

    public static void setRegisterBouncyCastle(boolean registerBouncyCastle)

### setSecurityProvider

    public static void setSecurityProvider(String securityProvider)

  Specifies the JCE security provider that should be used.

  Parameters:
    `securityProvider` - identifier for the security provider

Copyright © 2009-2011. All Rights Reserved.