+
+static int comp_alg_id(const void *a, const void *b)
+{
+ const struct schan_alg_id_name *lhs = a;
+ const struct schan_alg_id_name *rhs = b;
+ return (int)lhs->alg_id - (int)rhs->alg_id;
+}
+
+static void* get_alg_name(ALG_ID id, BOOL wide)
+{
+ static const WCHAR ecdsaW[] = {'E','C','D','S','A',0};
+ static const WCHAR rsaW[] = {'R','S','A',0};
+ static const WCHAR desW[] = {'D','E','S',0};
+ static const WCHAR rc2W[] = {'R','C','2',0};
+ static const WCHAR triple_desW[] = {'3','D','E','S',0};
+ static const WCHAR aesW[] = {'A','E','S',0};
+ static const WCHAR rc4W[] = {'R','C','4',0};
+ static const struct schan_alg_id_name alg_name_map[] = {
+ { CALG_ECDSA, "ECDSA", ecdsaW },
+ { CALG_RSA_SIGN, "RSA", rsaW },
+ { CALG_DES, "DES", desW },
+ { CALG_RC2, "RC2", rc2W },
+ { CALG_3DES, "3DES", triple_desW },
+ { CALG_AES_128, "AES", aesW },
+ { CALG_AES_192, "AES", aesW },
+ { CALG_AES_256, "AES", aesW },
+ { CALG_RC4, "RC4", rc4W },
+ };
+ const struct schan_alg_id_name *res;
+ struct schan_alg_id_name key;
+
+ key.alg_id = id;
+ res = bsearch(&key, alg_name_map,
+ sizeof(alg_name_map)/sizeof(alg_name_map[0]), sizeof(alg_name_map[0]),
+ comp_alg_id);