Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. cryptImportkey

cryptImportkey

Scheduled Pinned Locked Moved C / C++ / MFC
testingbeta-testingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 2070738
    wrote on last edited by
    #1

    Hi! How do I calculate the value of dwBloblen of pbKeyBlob read from a file.Even if i use the number of byted read returned from the CFile read function the key import function fail.How does the know the receiving side know the size of KEYBLOB. ////read KEYBLOB from a received file CFile file; BYTE *pbKeyBlob1 = NULL; DWORD dwBlobLen1=512; //just for testing but doesnt work for RSA //signature pbKeyBlob1 = (BYTE*)malloc(dwBlobLen1); // Read the key BLOB from the file. if(file.Open("key.txt",CFile::modeRead)) { file.Read(pbKeyBlob1,dwBlobLen1); file.Close(); } // call CryptImportKey if(CryptImportKey( hProv, pbKeyBlob1, dwBlobLen1, 0, 0, &hPubKey)) { MessageBox("The key has been imported"); } else { MessageBox("The key import failed"); }

    J 1 Reply Last reply
    0
    • U User 2070738

      Hi! How do I calculate the value of dwBloblen of pbKeyBlob read from a file.Even if i use the number of byted read returned from the CFile read function the key import function fail.How does the know the receiving side know the size of KEYBLOB. ////read KEYBLOB from a received file CFile file; BYTE *pbKeyBlob1 = NULL; DWORD dwBlobLen1=512; //just for testing but doesnt work for RSA //signature pbKeyBlob1 = (BYTE*)malloc(dwBlobLen1); // Read the key BLOB from the file. if(file.Open("key.txt",CFile::modeRead)) { file.Read(pbKeyBlob1,dwBlobLen1); file.Close(); } // call CryptImportKey if(CryptImportKey( hProv, pbKeyBlob1, dwBlobLen1, 0, 0, &hPubKey)) { MessageBox("The key has been imported"); } else { MessageBox("The key import failed"); }

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      The length of the Key BLOB depends on its type. Take a look here: Base Provider Key BLOBs[^] But shouldn't the length equal the file length? You can obtain it using CFile's GetLength method after opening it. -- jlr http://jlamas.blogspot.com/[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups