Package com.maverick.util

Examples of com.maverick.util.ByteArrayReader.readString()


    public byte[] decryptKeyblob(byte[] formattedKey, String passphrase)
        throws InvalidKeyException {
        try {
            byte[] keyblob = getKeyBlob(formattedKey);
            ByteArrayReader bar = new ByteArrayReader(keyblob);
            String type = bar.readString();

            if (type.equalsIgnoreCase("3des-cbc")) {
                // Decrypt the key
                byte[] keydata = makePassphraseKey(passphrase);
                byte[] iv = new byte[8];
View Full Code Here


            //this.hostKey = hostKey;
            RSAPublicKeySpec rsaKey;

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }
View Full Code Here

        try {
            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(encoded);

            // Read the public key
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }
View Full Code Here

     */
    public static SshPrivateKey decodePrivateKey(byte[] encoded)
        throws InvalidKeyException {
        try {
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String algorithm = bar.readString();

            if (supportsKey(algorithm)) {
                SshKeyPair pair = newInstance(algorithm);

                return pair.decodePrivateKey(encoded);
View Full Code Here

     */
    public static SshPublicKey decodePublicKey(byte[] encoded)
        throws InvalidKeyException {
        try {
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String algorithm = bar.readString();

            if (supportsKey(algorithm)) {
                SshKeyPair pair = newInstance(algorithm);

                return pair.decodePublicKey(encoded);
View Full Code Here

     * @return String
     */
    public String getAlgorithm() {
      try {
      ByteArrayReader r = new ByteArrayReader(keyblob);
      return r.readString();
    } catch (IOException e) {
      return null;
    }
    }

View Full Code Here

     *
     * @throws IOException
     */
    public SshPublicKey toPublicKey() throws IOException, InvalidKeyException {
        ByteArrayReader bar = new ByteArrayReader(keyblob);
        String type = bar.readString();
        SshKeyPair pair = SshKeyPairFactory.newInstance(type);

        return pair.decodePublicKey(keyblob);
    }

View Full Code Here

     * @return String
     */
    private String getAlgorithm(byte[] raw) {
        try {
      ByteArrayReader r = new ByteArrayReader(raw);
      return r.readString();
    } catch (IOException e) {
      return null;
    }
    }
}
View Full Code Here

        try {
            DSAPublicKeySpec dsaKey;

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }
View Full Code Here

        try {
            DSAPrivateKeySpec dsaKey;

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.