Ejemplo n.º 1
0
static void GetHashAlgorithmTypeAndSize(const char* mac,
                                        size_t macLength,
                                        HashAlgorithmType& dataHashAlg,
                                        DataHashSize& hashKeySize)
{
    if (StringSpanEquals(mac, "MD5", macLength))
    {
        dataHashAlg = HashAlgorithmType::Md5;
        hashKeySize = DataHashSize::MD5_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "SHA1", macLength))
    {
        dataHashAlg = HashAlgorithmType::Sha1;
        hashKeySize = DataHashSize::SHA1_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "GOST94", macLength))
    {
        dataHashAlg = HashAlgorithmType::SSL_GOST94;
        hashKeySize = DataHashSize::GOST_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "GOST89", macLength))
    {
        dataHashAlg = HashAlgorithmType::SSL_GOST89;
        hashKeySize = DataHashSize::GOST_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "SHA256", macLength))
    {
        dataHashAlg = HashAlgorithmType::SSL_SHA256;
        hashKeySize = DataHashSize::SHA256_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "SHA384", macLength))
    {
        dataHashAlg = HashAlgorithmType::SSL_SHA384;
        hashKeySize = DataHashSize::SHA384_HashKeySize;
        return;
    }
    if (StringSpanEquals(mac, "AEAD", macLength))
    {
        dataHashAlg = HashAlgorithmType::SSL_AEAD;
        hashKeySize = DataHashSize::Default;
        return;
    }

    dataHashAlg = HashAlgorithmType::None;
    hashKeySize = DataHashSize::Default;
}
Ejemplo n.º 2
0
static ExchangeAlgorithmType MapExchangeAlgorithmType(const char* keyExchange, size_t keyExchangeLength)
{
    if (StringSpanEquals(keyExchange, "RSA", keyExchangeLength))
        return ExchangeAlgorithmType::RsaKeyX;
    if (StringSpanEquals(keyExchange, "DH/RSA", keyExchangeLength))
        return ExchangeAlgorithmType::DiffieHellman;
    if (StringSpanEquals(keyExchange, "DH/DSS", keyExchangeLength))
        return ExchangeAlgorithmType::DiffieHellman;
    if (StringSpanEquals(keyExchange, "DH", keyExchangeLength))
        return ExchangeAlgorithmType::DiffieHellman;
    if (StringSpanEquals(keyExchange, "KRB5", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_kKRB5;
    if (StringSpanEquals(keyExchange, "ECDH", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_ECDHE;
    if (StringSpanEquals(keyExchange, "ECDH/RSA", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_ECDH;
    if (StringSpanEquals(keyExchange, "ECDH/ECDSA", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_ECDSA;
    if (StringSpanEquals(keyExchange, "PSK", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_kPSK;
    if (StringSpanEquals(keyExchange, "GOST", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_kGOST;
    if (StringSpanEquals(keyExchange, "SRP", keyExchangeLength))
        return ExchangeAlgorithmType::SSL_kSRP;

    return ExchangeAlgorithmType::None;
}
Ejemplo n.º 3
0
static CipherAlgorithmType MapCipherAlgorithmType(const char* encryption, size_t encryptionLength)
{
    if (StringSpanEquals(encryption, "DES(56)", encryptionLength))
        return CipherAlgorithmType::Des;
    if (StringSpanEquals(encryption, "3DES(168)", encryptionLength))
        return CipherAlgorithmType::TripleDes;
    if (StringSpanEquals(encryption, "RC4(128)", encryptionLength))
        return CipherAlgorithmType::Rc4;
    if (StringSpanEquals(encryption, "RC2(128)", encryptionLength))
        return CipherAlgorithmType::Rc2;
    if (StringSpanEquals(encryption, "None", encryptionLength))
        return CipherAlgorithmType::Null;
    if (StringSpanEquals(encryption, "IDEA(128)", encryptionLength))
        return CipherAlgorithmType::SSL_IDEA;
    if (StringSpanEquals(encryption, "SEED(128)", encryptionLength))
        return CipherAlgorithmType::SSL_SEED;
    if (StringSpanEquals(encryption, "AES(128)", encryptionLength))
        return CipherAlgorithmType::Aes128;
    if (StringSpanEquals(encryption, "AES(256)", encryptionLength))
        return CipherAlgorithmType::Aes256;
    if (StringSpanEquals(encryption, "Camellia(128)", encryptionLength))
        return CipherAlgorithmType::SSL_CAMELLIA128;
    if (StringSpanEquals(encryption, "Camellia(256)", encryptionLength))
        return CipherAlgorithmType::SSL_CAMELLIA256;
    if (StringSpanEquals(encryption, "GOST89(256)", encryptionLength))
        return CipherAlgorithmType::SSL_eGOST2814789CNT;
    if (StringSpanEquals(encryption, "AESGCM(128)", encryptionLength))
        return CipherAlgorithmType::Aes128;
    if (StringSpanEquals(encryption, "AESGCM(256)", encryptionLength))
        return CipherAlgorithmType::Aes256;

    return CipherAlgorithmType::None;
}