Problem with CRYPTOAPI

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;
davinder101Asked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (250)

Computer101
EE Admin
0
 
mahesh1402Commented:
The fuction failing on decryption is CryptImportKey();

what GetLastError returns ?

-MAHESH
0
 
davinder101Author Commented:
The value return by GetLastError() is 2148073477.
Thanks
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
mahesh1402Commented:
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
 
davinder101Author Commented:
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
 
davinder101Author Commented:
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
 
mahesh1402Commented:
Is this you are looking for ?
http://support.microsoft.com/kb/228786
0
 
Mayur SaswadeCommented:
Thanks
0
All Courses

From novice to tech pro — start learning today.