Exemple #1
0
int AsymmCipher::decrypt(const byte* cipher, int cipherlen, byte* out, int numbytes)
{
    Integer m;

    if (!decodeintarray(&m, 1, cipher, cipherlen))
    {
        return 0;
    }

    rsadecrypt(key, &m);

    unsigned l = key[AsymmCipher::PRIV_P].ByteCount() + key[AsymmCipher::PRIV_Q].ByteCount() - 2;

    if (m.ByteCount() > l)
    {
        l = m.ByteCount();
    }

    l -= numbytes;

    while (numbytes--)
    {
        out[numbytes] = m.GetByte(l++);
    }

    return 1;
}
Exemple #2
0
int AsymmCipher::decrypt(const byte* c, int cl, byte* out, int numbytes)
{
    Integer m;

    if (!decodeintarray(&m,1,c,cl)) return 0;

    rsadecrypt(key,&m);

    unsigned l = key[AsymmCipher::PRIV_D].ByteCount()-2;

    if (m.ByteCount() > l) l = m.ByteCount();

    l -= numbytes;

    while (numbytes--) out[numbytes] = m.GetByte(l++);

    return 1;
}
Exemple #3
0
int AsymmCipher::setkey(int numints, const byte* data, int len)
{
    int ret = decodeintarray(key, numints, data, len);
    padding = (numints == PUBKEY && ret) ? (len - key[PUB_PQ].ByteCount() - key[PUB_E].ByteCount() - 4) : 0;
    return ret;
}
Exemple #4
0
int AsymmCipher::setkey(int numints, const byte* data, int len)
{
    return decodeintarray(key, numints, data, len);
}