/*
(non-Javadoc)

@see
com.sshtools.publickey.SshPrivateKeyFile#toPrivateKey(java.lang.String)
15610
public SshKeyPair toKeyPair(String passphrase) throws IOException,
			InvalidPassphraseException {

		ByteArrayReader bar = new ByteArrayReader(decryptKey(passphrase));

		try {
			// Process the actual key and return the key pair

			String algorithm = bar.readString();

			if (algorithm.equals("ssh-dss")) {
				BigInteger p = bar.readBigInteger();
				BigInteger q = bar.readBigInteger();
				BigInteger g = bar.readBigInteger();
				BigInteger x = bar.readBigInteger();

				SshDsaPrivateKey prv = ComponentManager.getInstance()
						.createDsaPrivateKey(p, q, g, x, g.modPow(x, p));
				SshKeyPair pair = new SshKeyPair();

				pair.setPublicKey(prv.getPublicKey());
				pair.setPrivateKey(ComponentManager.getInstance()
						.createDsaPrivateKey(p, q, g, x, g.modPow(x, p)));

				return pair;

			} else if (algorithm.equals("ssh-rsa")) {

				BigInteger publicExponent = bar.readBigInteger();
				BigInteger modulus = bar.readBigInteger();

				// Read the private key
				BigInteger privateExponent = bar.readBigInteger();

				SshKeyPair pair = new SshKeyPair();
				pair.setPublicKey(ComponentManager.getInstance()
						.createRsaPublicKey(modulus, publicExponent));
				pair.setPrivateKey(ComponentManager.getInstance()
						.createRsaPrivateKey(modulus, privateExponent));

				return pair;

			} else {
				throw new IOException("Unsupported private key algorithm type "
						+ algorithm);
			}
		} catch (SshException e) {
			throw new SshIOException(e);
		} finally {
			try {
				bar.close();
			} catch (IOException e) {
			}
		}

	}
637632
protected String resolveProtocolKey(String key) {
        return MotorbikeSecurityType.SSL.equals(securityType) ? Srl.replace(key, ".smtp.", ".smtps.") : key;
    }
922839
public void remove(SshPublicKey key) throws SshException,
			PublicKeySubsystemException {

		try {

			Packet msg = createPacket();
			msg.writeString("remove");
			msg.writeString(key.getAlgorithm());
			msg.writeBinaryString(key.getEncoded());

			sendMessage(msg);

			readStatusResponse();

		} catch (IOException ex) {
			throw new SshException(ex);
		}
	}
773049
public boolean setTxMasterKey(byte[] key) {
		boolean res = false;
		if ((key.length == MASTER_KEY_SIZE_32_BYTES)
				|| (key.length == MASTER_KEY_SIZE_16_BYTES)) {
			txMasterKey = null;
			txMasterKey = platform.getUtils().copy(key);
			res = true;
			logDebug("setTxMasterKey "
					+ platform.getUtils().byteToHexString(txMasterKey));
		} else {
			logError("Wrong length iTxMasterKey: " + key.length);
		}
		return res;
	}
289404
public char getStopKey() {
        String value = Optional.fromNullable(getParameter(SignalParameters.STOP_KEY.symbol())).or("");
        return value.isEmpty() ? ' ' : value.charAt(0);
    }
1268557
private void checkKey(final String key) {

		/*
		 * Get hashtag from the first host of the active pool We cannot use the
		 * connection object because as of now we have not selected a connection. A
		 * connection is selected based on the key or hashtag respectively.
		 */
		String hashtag = connPool.getConfiguration().getHashtag();
		if (hashtag == null || hashtag.isEmpty()) {
			if (theKey.get() != null) {
				verifyKey(key);
			} else {
				boolean success = theKey.compareAndSet(null, key);
				if (!success) {
					// someone already beat us to it. that's fine, just verify
					// that the key is the same
					verifyKey(key);
				} else {
					pipelined(key);
				}
			}
		} else {
			/*
			 * We have a identified a hashtag in the Host object. That means Dynomite has a
			 * defined hashtag. Producing the hashvalue out of the hashtag and using that as
			 * a reference to the pipeline
			 */
			String hashValue = StringUtils.substringBetween(key, Character.toString(hashtag.charAt(0)),
					Character.toString(hashtag.charAt(1)));
			if (Strings.isNullOrEmpty(hashValue)) {
				hashValue = key;
			}
			checkHashtag(key, hashValue);
		}
	}
260853
static public Key make(String s, byte rf, byte systemType, H2ONode... replicas) {
    return make(decodeKeyName(s),rf,systemType,replicas);
  }
282499
public void sshKey_keyName_PUT(String keyName, OvhSshKey body) throws IOException {
		String qPath = "/me/sshKey/{keyName}";
		StringBuilder sb = path(qPath, keyName);
		exec(qPath, "PUT", sb.toString(), body);
	}
827713
@Override
    public PrivateKey getPrivateKey(String s) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getPrivateKey", new Object[] { s });

        PrivateKey rc = getX509KeyManager().getPrivateKey(s);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getPrivateKey -> " + (null != rc));
        return rc;
    }
569919
public void setKey(org.openprovenance.prov.model.Key value) {
        this.key = (org.openprovenance.prov.sql.Key)value;
    }
1305668
@SuppressWarnings("ReferenceEquality")
  public boolean hasTemplateKey(TemplateType templateKey) {
    // Note: match by identity, not equality
    for (TemplateType entry : templateKeys) {
      if (entry == templateKey) {
        return true;
      }
    }
    return false;
  }
801652
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, PrivateKey key) {
        // We can take a shortcut if the private key happens to be already
        // PEM/PKCS#8 encoded. This is the ideal case and reason why all
        // this exists. It allows the user to pass pre-encoded bytes straight
        // into OpenSSL without having to do any of the extra work.
        if (key instanceof PemEncoded) {
            return ((PemEncoded) key).retain();
        }

        byte[] bytes = key.getEncoded();
        if (bytes == null) {
            throw new IllegalArgumentException(key.getClass().getName() + " does not support encoding");
        }

        return toPEM(allocator, useDirect, bytes);
    }
168966
public static <T> Principal getPrincipalForCredential(final PropertyKey<T> key, final T value) {

		return getPrincipalForCredential(key, value, false);

	}
894875
public static PublicKey createPublicKey(byte[] publicKey) {
    if (publicKey == null) {
      return null;
    }
    
    try {
      KeyFactory fac = KeyFactory.getInstance("RSA");
      EncodedKeySpec spec = new X509EncodedKeySpec(publicKey);
      return fac.generatePublic(spec);
    }
    catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException(e);
    }
    catch (InvalidKeySpecException e) {
      throw new IllegalStateException(e);
    }
  }
1148443
private void storeKey(SecretKey key) {
        final String keyStoreFile = getMain().getFileSystemManager().getSystemLocation() + File.separator + "izou.keystore";
        KeyStore keyStore = createKeyStore(keyStoreFile, "4b[X:+H4CS&avY<)");

        try {
            KeyStore.SecretKeyEntry keyStoreEntry = new KeyStore.SecretKeyEntry(key);
            KeyStore.PasswordProtection keyPassword = new KeyStore.PasswordProtection("Ev45j>eP}QTR?K9_".toCharArray());
            keyStore.setEntry("izou_key", keyStoreEntry, keyPassword);
            keyStore.store(new FileOutputStream(keyStoreFile), "4b[X:+H4CS&avY<)".toCharArray());
        } catch (NoSuchAlgorithmException | KeyStoreException
                | CertificateException | IOException e) {
            logger.error("Unable to store key", e);
        }
    }
404129
function privKeyToPubKey(privKey, toCompressed) {
  toCompressed = toCompressed || false;

  const pkBuffer = Buffer.from(privKey, 'hex');
  var publicKey = secp256k1.publicKeyCreate(pkBuffer, toCompressed);
  return publicKey.toString('hex');
}
704147
public void sshKey_POST(String key, String keyName) throws IOException {
		String qPath = "/me/sshKey";
		StringBuilder sb = path(qPath);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "key", key);
		addBody(o, "keyName", keyName);
		exec(qPath, "POST", sb.toString(), o);
	}