Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with CRYPTOAPI

Posted on 2006-11-16
10
Medium Priority
?
1,245 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
8 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month6 days, 6 hours left to enroll

772 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