Пример #1
0
bool ne7ssh_crypt::makeKexSecret (Botan::SecureVector<Botan::byte> &result, Botan::BigInt &f)
{
    PK_Key_Agreement key_agreement(*privKexKey, "Raw");
    SymmetricKey negotiated = key_agreement.derive_key(32, (byte*)f.data(), f.bytes(), "");
//  SymmetricKey negotiated = privKexKey->derive_key (f);
  if (!negotiated.length()) return false;

  BigInt Kint (negotiated.begin(), negotiated.length());  
  ne7ssh_string::bn2vector(result, Kint);
  K = Botan::SecureVector<Botan::byte>(result);
  delete privKexKey;
  privKexKey = 0;
  return true;
}  
Пример #2
0
QByteArray AbstractSshPacket::encodeMpInt(const Botan::BigInt &number)
{
    if (number.is_zero())
        return QByteArray(4, 0);

    int stringLength = number.bytes();
    const bool positiveAndMsbSet = number.sign() == Botan::BigInt::Positive
                                   && (number.byte_at(stringLength - 1) & 0x80);
    if (positiveAndMsbSet)
        ++stringLength;
    QByteArray data;
    data.resize(4 + stringLength);
    int pos = 4;
    if (positiveAndMsbSet)
        data[pos++] = '\0';
    number.binary_encode(reinterpret_cast<Botan::byte *>(data.data()) + pos);
    setLengthField(data);
    return data;
}