void dec_gost(char *set_hash,char *in,char **out,int n_blocks){ gost_ctx *c=(gost_ctx *)malloc(sizeof(gost_ctx)); gost_subst_block *b=NULL; gost_init(c,b); gost_key(c,(byte *)set_hash); *out=NULL; *out=(char *)malloc(n_blocks*8); gost_dec(c,(byte *)in,(byte *) *out,n_blocks); }
int keyUnwrapCryptoPro(gost_ctx *ctx,const unsigned char *keyExchangeKey, const unsigned char *wrappedKey, unsigned char *sessionKey) { unsigned char kek_ukm[32],cek_mac[4]; keyDiversifyCryptoPro(ctx,keyExchangeKey,wrappedKey /* First 8 bytes of wrapped Key is ukm */ ,kek_ukm); gost_key(ctx,kek_ukm); gost_dec(ctx,wrappedKey+8,sessionKey,4); gost_mac_iv(ctx,32,wrappedKey,sessionKey,32,cek_mac); if (memcmp(cek_mac,wrappedKey+40,4)) { return 0; } return 1; }