473,797 Members | 2,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CryptGetUserKey works in WinXP but fails in Win2000

Does anyone have any ideas about why the Crypto API call to
CryptGetUserKey (…)would work just fine in WindowsXP but fails when
executed in Windows2000? The call is made in code that is practically
identical to the well known file encryption example found in the MSDN
help (see ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/security/security/example_c_progr am_encrypting_a _file.htm
if you have MSDN installed on your machine) and attempts to use the
AT_KEYEXCHANGE private key from the key container. GetLastError() is
returning NTE_NO_KEY signifying that "The key requested by the
dwKeySpec parameter does not exist."

Any assistance is appreciated,

OrrisJ
------------- CODE FRAGMENT BELOW ------------------------------------
IDataBufferPtrH andle Encrypt( IDataBufferPtrH andle pdbUnEncryptedD ata
)
{

***** Code Deleted ***************

///////////////////////////////////////////////////////
// Get the handle to the default key container within
// the default cryptographic service provider (CSP).
///////////////////////////////////////////////////////

if( !CryptAcquireCo ntext( &m_hCryptPro v, NULL, MS_ENHANCED_PRO V,
PROV_RSA_FULL, 0 ) )
{
CErrorMsg( method, _T( "Error %x during CryptAcquireCon text!\n" ),
GetLastError() );
CleanUp();
return NULL;
}

///////////////////////////////////////////////////////
// Encrypt using a random session key derived from
// the current users windows credentials. The ramdom
// session key and its size is saved along with the
// data.
///////////////////////////////////////////////////////

///////////////////////////////////////////////////////
// Create a random session key.

if( !CryptGenKey( m_hCryptProv, ENCRYPT_ALGORIT HM, KEYLENGTH |
CRYPT_EXPORTABL E, &m_hKey ) )
{
CErrorMsg( method, _T( "Error %x during CryptGenKey.\n" ),
GetLastError() );
CleanUp();
return NULL;
}

///////////////////////////////////////////////////////
// Get the handle to the encrypter's exchange public
// key.

if( !CryptGetUserKe y( m_hCryptProv, AT_KEYEXCHANGE, &m_hXchgKey ) )
{
CErrorMsg( method, _T( "Error %x User public key is not available
and may not exist.\n" ), GetLastError() );
CleanUp();
return NULL;
}

***** Code Deleted ***************
///////////////////////////////////////////////////////
// Export the session key into a simple key BLOB.

if( !CryptExportKey ( m_hKey, m_hXchgKey, SIMPLEBLOB, 0, m_pbKeyBlob,
&dwKeyBlobLengt h ) )
{
CErrorMsg( method, _T( "Error %x during CryptExportKey! \n" ),
GetLastError() );
CleanUp();
return NULL;
}

***** Code Deleted ***************

///////////////////////////////////////////////////////
// Encrypt the data. After the successfull call to
// CryptEncrypt, dwDataLength will contain the length
// of the encrypted buffer.
///////////////////////////////////////////////////////

if( !CryptEncrypt( m_hKey, 0, TRUE, 0, m_pbBuffer, &dwDataLengt h,
dwBufferLength) )
{
CErrorMsg( method, _T( "Error %x during CryptEncrypt!\n " ),
GetLastError() );
CleanUp();
return NULL;
}

///////////////////////////////////////////////////////
// Save key, key length, encrypted data and data length
// into the data buffer.

***** Code Deleted ***************

CleanUp();
return pIEncryptedData ;
}
Jul 22 '05 #1
2 2897
"WilOJoe" <oj*****@filene t.com> wrote...
Does anyone have any ideas about why the Crypto API call to
CryptGetUserKey (.)would work just fine in WindowsXP but fails when
executed in Windows2000? [..][


Somebody in a newsgroup where it's on topic is likely able
to answer this. Try comp.os.ms-windows.program mer.win32

Victor
Jul 22 '05 #2
Thanks...I will try posting to comp.os.ms-windows.program mer.win32 as you suggest.

OrrisJ
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1555
by: Steve | last post by:
My access 2000 project was written on a win 98 machine and has a macro with a condition DateValue(FileDateTime("c:\database\full22.txt"))<Date() This was written in expression builder. On the Win 98 machine all works fine. When using same datbase on a Win 2000 machine this
2
1680
by: MJC | last post by:
Hi All, I just built a database in Access XP/Win XP and am having an issue with the enter key behavior when the database is run under Windows 2000. If you use the enter key to tab through the fields on the forms you eventually get to the 'close' button. Under WinXP pressing enter again once the button has focus will cause Access to initiate the code on the On Click event. Under Win 2000 the focus moves to the top field on the form.
2
1394
by: Grei | last post by:
how can i impersonate from win2000 to WinXP? in MSDN says: (gives example how to implemet it but not with win2000, and it doesn't say what to do on win2000!!!) any ideas? workarounds? Thanx! // This sample demonstrates the use of the WindowsIdentity class to impersonate a user.
6
1629
by: Grei | last post by:
how can i impersonate from win2000 to WinXP? MSDN gives example how to implemet impersonation from XP to XP, but not from win2000 to XP, and it doesn't say what to do with win2000!!! any ideas? workarounds? Thanx! // This sample demonstrates the use of the WindowsIdentity class to
0
1347
by: Vincent Finn | last post by:
Hi, I am trying to use CreateProcessWithLogon in VB.net My code works fine when on a WinXP machine but fails on a Win2000 machine The error is "Object reference not set to an instance of an object"
4
1617
by: Strahimir Antoljak | last post by:
I completed a VB.NET application and it runs fine on WinXP. I wanted to run it on Win2000 and it is not working. Is it not supposed to work on Win2000 too? (I installed .NET framework distributable on the Win2000 machine). Any suggestion much appreciated. Thanks, -- Strah @ Langan
10
2409
by: JP Bless | last post by:
Hi all, I have a database Access/MSDE and would like to have a website so users can search the data and update some records/fields through the website.... And I have high speed internet connection. Is it possible to setup/host a website using WIN2000/XP machine? Must I have static IP and not dynamic one obtained when my router connects to the ISP? What kind of internet connection do I need to have to be able to have/host a website on my...
1
1477
by: thianseng | last post by:
Hi All, Urgent SOS!!! I developed my project using pyton 2.5 under winXP and had an issue in loading my dll if the target user is using Win2000. Initially, I thought it was caused by the dlls I created were not compatible with Win2k. Then, I wrote a simple MFC program to load the dlls. It works fine for MFC but not for ctypes(python 2.5). Can someone please help? Thanks...... Best regards, Vincent....
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.