byte[] blob = _readBuffer.getString();
byte[] data = _readBuffer.getString();
@SuppressWarnings("unused")
int flags = _readBuffer.getInt();
Identity identity = null;
synchronized ( identities ) {
for( Identity _identity : identities ) {
if( _identity.getPublicKeyBlob() == null ) {
continue;
}
if( !Arrays.equals(blob, _identity.getPublicKeyBlob()) ) {
continue;
}
if( _identity.isEncrypted() ) {
if( userinfo == null ) {
continue;
}
while( _identity.isEncrypted() ) {
if( !userinfo.promptPassphrase(String.format(MessageConstants.PROMPT_PASSPHRASE, _identity.getName())) ) {
break;
}
String _passphrase = userinfo.getPassphrase();
if( _passphrase == null ) {
break;
}
byte[] passphrase = Util.str2byte(_passphrase);
try {
if( _identity.setPassphrase(passphrase) ) {
break;
}
} catch(JSchException e) {
break;
}
}
}
if( !_identity.isEncrypted() ) {
identity = _identity;
break;
}
}
}
byte[] signature = null;
if( identity != null ) {
signature = identity.getSignature(data);
}
_messageBuffer.reset();
if( signature == null ) {
_messageBuffer.putByte(SSH2_AGENT_FAILURE);