[2/2] [v2] secur32: Add support for SECPKG_ATTR_KEY_INFO.

Jacek Caban jacek at codeweavers.com
Fri Apr 21 10:38:19 CDT 2017


Hi Akihiro,

The patch looks mostly good now, thanks. I have a few minor comments.

On 20.04.2017 13:58, Akihiro Sagawa wrote:
> +struct schan_alg_id_name {
> +    ALG_ID alg_id;
> +    const char* name;
> +    const WCHAR *nameW;
> +};

Using an array here like const WCHAR nameW[8]; would make later 
initialization nicer by not requiring multiple string variables.

> +
> +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);

You could use id directly as a key. You don't need it to be of 
schan_alg_id_name* type, the key may be just ALG_ID.

Thanks,
Jacek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20170421/80edd500/attachment.html>


More information about the wine-devel mailing list