Solved

Problem with CRYPTOAPI

Posted on 2006-11-16
10
1,179 Views
Last Modified: 2016-08-23
Hi, i am using cryptoapi to encrypt my files. The files are decrypted if i decrypt them on the same system with same user, but if i try to decrypt them with different user or on different system, decryption fails. The function i am using to encrypt files are:-
        CryptAcquireContext();
      CryptGetUserKey(  );
        CryptGetUserKey(  );
       GeneratePrivateKey();
       CryptGenKey();
etc.
The fuction failing on decryption is
      CryptImportKey();
Can anybody tell how to decrypt files on a different system;
Thanks;
0
Comment
Question by:davinder101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17963075
The fuction failing on decryption is CryptImportKey();

what GetLastError returns ?

-MAHESH
0
 

Author Comment

by:davinder101
ID: 17963113
The value return by GetLastError() is 2148073477.
Thanks
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17963128
and what CryptImportKey() returns out of following ?

ERROR_INVALID_HANDLE
ERROR_INVALID_PARAMETER
NTE_BAD_ALGID
NTE_BAD_DATA
NTE_BAD_FLAGS
NTE_BAD_TYPE
NTE_BAD_UID
NTE_BAD_VER

look into return error code and try to change accordingly.

-MAHESH
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:davinder101
ID: 17963186
The value is NTE_BAD_DATA. But why it is decrypting on the same machine.
I think it has something to do with the public key used to form the public-private key pair.
Thanks.
0
 

Author Comment

by:davinder101
ID: 17977846
Hi, from microsoft news group, i came to know that during encryption one has to encypt the file by using the private key of the source system and the public key of the destination system. Then only we can decrypt the file on the destination system. Can any one tell me how to get the key from the destiantion system.
Thanks,
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17977895
Is this you are looking for ?
http://support.microsoft.com/kb/228786
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18473170
PAQed with points refunded (250)

Computer101
EE Admin
0
 

Expert Comment

by:Mayur Saswade
ID: 41768259
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question