Ejemplo n.º 1
0
const cipher_kt_t *get_cipher_type(int method)
{
    if (method <= TABLE || method >= CIPHER_NUM) {
        LOGE("get_cipher_type(): Illegal method");
        return NULL;
    }

    if (method == RC4_MD5) {
        method = RC4;
    }

    if (method >= SALSA20) {
        return NULL;
    }

    const char *ciphername = supported_ciphers[method];
#if defined(USE_CRYPTO_OPENSSL)
    return EVP_get_cipherbyname(ciphername);
#elif defined(USE_CRYPTO_POLARSSL)
    const char *polarname = supported_ciphers_polarssl[method];
    if (strcmp(polarname, CIPHER_UNSUPPORTED) == 0) {
        LOGE("Cipher %s currently is not supported by PolarSSL library",
             ciphername);
        return NULL;
    }
    return cipher_info_from_string(polarname);
#endif
}
Ejemplo n.º 2
0
    _cipher_init()
    {
        int32_t i, j, k;

        for (i = 0; i < PROVIDER_COUNT; i ++)
            for (j = 0; j < SIZE_COUNT; j ++)
                if (s_sizes[i][j].name)
                    for (k = 0; k < MODE_COUNT; k ++)
                    {
                        std::string name = s_sizes[i][j].name;

                        name.append(s_modes[k]);
                        s_sizes[i][j].cis[k] = cipher_info_from_string(name.c_str());
                        if (s_sizes[i][j].cis[k])
                            s_sizes[i][j].size = s_sizes[i][j].cis[k]->key_length;
                    }
    }
Ejemplo n.º 3
0
const cipher_info_t *
cipher_kt_get (const char *ciphername)
{
  const cipher_info_t *cipher = NULL;

  ASSERT (ciphername);

  cipher = cipher_info_from_string(ciphername);

  if (NULL == cipher)
    msg (M_FATAL, "Cipher algorithm '%s' not found", ciphername);

  if (cipher->key_length/8 > MAX_CIPHER_KEY_LENGTH)
    msg (M_FATAL, "Cipher algorithm '%s' uses a default key size (%d bytes) which is larger than " PACKAGE_NAME "'s current maximum key size (%d bytes)",
	 ciphername,
	 cipher->key_length/8,
	 MAX_CIPHER_KEY_LENGTH);

  return cipher;
}