示例#1
0
bool ne7ssh_crypt::getDHGroup14Sha1Public (Botan::BigInt &publicKey)
{
#if BOTAN_PRE_15
  privKexKey = new DH_PrivateKey (get_dl_group("IETF-2048"));
#elif BOTAN_PRE_18
  privKexKey = new DH_PrivateKey (DL_Group("modp/ietf/2048"));
#else
  privKexKey = new DH_PrivateKey (*ne7ssh::rng, DL_Group("modp/ietf/2048"));
#endif
  DH_PublicKey pubKexKey = *privKexKey;

  publicKey = pubKexKey.get_y();
  if (publicKey.is_zero()) return false;
  else 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;
}