Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > VB6 program - Crypto Failure Trying to Create Container.

Reply
Thread Tools Display Modes

VB6 program - Crypto Failure Trying to Create Container.

 
 
DrShell
Guest
Posts: n/a

 
      09-19-2010
I'm hoping someone here can help me on this...if not, please direct me
to a group that can.

I've got a VB6 program that uses the Windows Cryptographic Provider in
Win2K. In it's upgrades I've taken it up through XP and into Vista.
It was, until Vista, a very stable program. Now it fails to create
the Key Container. I've had the user run in Administrator to attempt
to give the program the authority it needs to do this, but it still
fails.

I don't have Vista on my development system (or any of my systems for
that matter), so I can't walk through the code to see what's
happening.

Can someone take a look at my code and see if there is anything wrong?
Thanks in advance for any help.

The following code uses:
o abKeyCon is a Byte Array with the Container name
o abSerPro is a Byte Array with the value
"Microsoft Enhanced Cryptographic Provider v1.0"
Note: Both of these arrays are converted from Unicode strings and have
chr(0) as a terminator.

Failure occurs on the CryptAcquireContext and is handled, with error
code, back to the calling part of the program. There is no
err.LastDllError so I have no idea what is causing the problem.

Watch for line wrap ;-)

_____________Start_Code_________________
Public Property Let KeyContainerName(strKeyConName As String)

lngLastError = 0
If Len(strKeyConName) > 0 Then
ReDim abKeyCon(Len(strKeyConName))
abKeyCon = StrConv(strKeyConName, vbFromUnicode) & vbNullChar
Else
ReDim abKeyCon(0)
abKeyCon(0) = vbNullChar
End If
End Property

Public Sub SessionEnd()

If hSessionKey <> 0 Then CryptDestroyKey hSessionKey
If hKeyPair <> 0 Then CryptDestroyKey hKeyPair
If hCryptProv <> 0 Then CryptReleaseContext hCryptProv, 0
End Sub

Public Function SessionStart(Optional sKeyCon As String, Optional
bFresh As Boolean = False) As Boolean
Dim lngReturnValue As Long

SessionEnd
lngLastError = 0
KeyContainerName = sKeyCon
If bFresh Then
lngReturnValue = CryptAcquireContext( _
hCryptProv, abKeyCon(0), abSerPro(0), PROV_RSA_FULL,
CRYPT_DELETEKEYSET _
)
If lngReturnValue = 0 Then Err.Clear
lngReturnValue = CryptAcquireContext( _
hCryptProv, abKeyCon(0), abSerPro(0), PROV_RSA_FULL,
CRYPT_NEWKEYSET _
)
If lngReturnValue = 0 Then
lngLastError = Err.LastDllError
Exit Function
End If
Else
lngReturnValue = CryptAcquireContext( _
hCryptProv, abKeyCon(0), abSerPro(0), PROV_RSA_FULL,
CRYPT_EXISTINGKEYSET _
)
If lngReturnValue = 0 Then
Err.Clear
lngReturnValue = CryptAcquireContext( _
hCryptProv, abKeyCon(0), abSerPro(0), PROV_RSA_FULL,
CRYPT_NEWKEYSET _
)
If lngReturnValue = 0 Then
lngLastError = Err.LastDllError
Exit Function
End If
End If
End If
SessionStart = True
End Function
_____________End Code________________
 
Reply With Quote
 
 
 
 
DrShell
Guest
Posts: n/a

 
      11-04-2010
Just to follow up on this post. I've determined that the Crypto code
was not in error. The culprit has not, as yet, been determined. But,
it is my assumtion that a virus/security program is blocking the calls
to the Crypto provider.

This assumtion is made due to the subject computer flagging a small
Crypto test program, I attempted to run on the system, as a virus.

The program has been installed on another system, by the user, and it
ran without a problem.

A big thanks to anyone who spent time looking this problem over. The
user is now trying to determine the problem concerning the virus
program on his system.

Regards,
Shell
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crypto Failure Trying to Create Container. DrShell Windows Vista Help 0 09-17-2010 12:04 AM
ANS: "What's the deal with UAC (Windows Needs Your Permission screens)" and "...But I thought I was an administrator" Jimmy Brush Windows Vista Administration 199 12-31-2009 07:58 AM
ANS: "What's the deal with UAC (Windows Needs Your Permission screens)" and "...But I thought I was an administrator" Jimmy Brush Windows Vista File Management 198 12-31-2009 07:58 AM
Security Failures after Password Change Zachary Server Security 14 10-30-2009 06:02 PM
cloning laptop sata harddrive vista premium Mark Ryan Windows Vista Hardware 5 04-26-2007 06:44 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59