当前位置:首页 » 多媒体相关

关于CryptoApi的调用问题,急,在线等待


微软msdn有这样一段demo代码,演示hash签名。  
   
  hcryptprov   hprov;  
  byte   *pbbuffer=   (byte   *)"the   data   that   is   to   be   hashed   and   signed.";  
  dword   dwbufferlen   =   strlen((char   *)pbbuffer)+1;  
  hcrypthash   hhash;  
  hcryptkey   hkey;  
  hcryptkey   hpubkey;  
  byte   *pbkeyblob;                  
  byte   *pbsignature;  
  dword   dwsiglen;  
  dword   dwbloblen;  
  lptstr   szdescription   =   "test   data   description";  
   
  //--------------------------------------------------------------------  
  //   acquire   a   csp.    
   
  if(cryptacquirecontext(  
        &hprov,    
        null,    
        null,    
        prov_rsa_full,    
        0))    
  {  
            printf("csp   context   acquired.\n");  
  }  
  else  
  {  
            handleerror("error   during   cryptacquirecontext.");  
  }  
  //--------------------------------------------------------------------  
  //   get   the   public   at   signature   key.   this   is   the   public   key  
  //   that   will   be   used   by   the   receiver   of   the   hash   to   verify  
  //   the   signature.   in   situations   where   the   receiver   could   obtain   the  
  //   senders   public   key   from   a   certificate,   this   step   would   not   be  
  //   needed.  
   
  if(cryptgetuserkey(        
        hprov,          
        at_signature,          
        &hkey))    
  {  
          printf("the   signature   key   has   been   acquired.   \n");  
  }  
  else  
  {  
          handleerror("error   during   cryptgetuserkey   for   signkey.");  
  }  
  =====================================================  
   
  我在使用时,调用cryptgetuserkey函数总是错误,错误代码是nte_no_key,大意是说at_signature参数所要求的key不存在,不知如何解决,请有经验的兄弟指点

.

推荐阅读

  • 惠普大幅面打印机俱乐部举行老用户注册抽奖 [详细内容]
  • 惠普公司收购Snapfish 扩展其在线照片业务 [详细内容]
  • Visual C++中的异常处理浅析 [详细内容]
  • 投资大陆24亿元 力晶半导体计划兴建芯片厂 [详细内容]
  • 惠普重金挖来新CEO 年薪加奖金达340万美元 [详细内容]
  • 8日精选 Java异常处理的陋习展播 [详细内容]
  • 短信保存技巧 [详细内容]
  • 网友回答:

    讨论区

    Login