Article View: alt.privacy.anon-server
Article #64430Re: spgp.dll key import function
From: Frog-Admin
Date: Fri, 11 Jul 2003 21:07
Date: Fri, 11 Jul 2003 21:07
175 lines
8818 bytes
8818 bytes
-----BEGIN PGP SIGNED MESSAGE-----
On 11 Jul 2003, Anonymous-Remailer@See.Comment.Header (Frog-Admin) wrote:
>HOW WEIRD!
>You should have a program crash!!!!
>Solution follows within 10 minutes.
Your problem is that your buffer is not initialized at all.
Documentation suggests to "guess" the size, but I rather use two passes:
- -1 to get the size
- -2 to really perform
YOU MUST HAVE THE LATEST VERSION OF SPGP.DLL
(actually, I had mention spgp_keyimportfile because of that version problem
while you were fighting with encryption APIs
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Here are 2 routines and declare from my Module_SPGP.bas,
which has been part of various programs running since 2003/01/01
RtvStrPGPKeyProps returns a *STRING*
RtvVariPGPKeyProps returns a *VARIANT* (and calls RtvStrPGPKeyProps)
RtvArrPGPKeyProps returns an *ARRAY* (and calls RtvStrPGPKeyProps)
but I recommend *against* RtvArrPGPKeyProps
and I don't supply it
______________
NONE actually updates the keyring: it is *just* to check the key properties
- -->Modify the corresponding boolean to actually perform the update
______________
Later, you might find some use to IsPGPKeyPropsEmpty
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Option Explicit
Option Compare Text
'############################################################################################
Public Type myPGPKeyProps
Priv As String
ID As String
Adr As String
Len As String
Date1 As String
Date2 As String
FP As String
R1 As String
R2 As String
Typ As String
End Type
'############################################################################################
'BEWARE: Both JBN2 and Reliable have a bug,
'use latest version of SPGP.dll
'Characterization: Y:\MetaStats\Bikikii_dsskeys.asc
'Other workaround: use spgp_keyimport instead of spgp_keyimportfile
Private Declare Function spgp_keyimportfile Lib "spgp.dll" _
(ByVal FileIn As String, _
ByVal KeyProps As String, _
ByVal KeyPropsLen As Long, _
ByVal Import As Long, _
ByVal AllProps As Long) _
As Long
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Function RtvStrPGPKeyProps(fN As String) As String
Dim r As Long
Dim sKeyProps As String
Dim lKeyPropsLen As Long
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If (Dir(fN) = "") Then
'MsgBox "File not found:" & vbCrLf & fN, vbCritical
GoTo EXITEXIT
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sKeyProps = String$(1, vbNullChar)
lKeyPropsLen = Len(sKeyProps)
r = spgp_keyimportfile(fN, sKeyProps, lKeyPropsLen, 0&, 1&)
If (r > 0) Then
lKeyPropsLen = r
sKeyProps = String(lKeyPropsLen, vbNullChar)
r = spgp_keyimportfile(fN, sKeyProps, lKeyPropsLen, 0&, 1&)
Else
sKeyProps = ""
MsgBox "spgp Error:" & r, vbCritical
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EXITEXIT:
RtvStrPGPKeyProps = sKeyProps
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Function
'############################################################################################
Public Function RtvVariPGPKeyProps(fN As String) As myPGPKeyProps()
Dim y01, y02, y03, y04, y05, y06, y07, y08, y09, y10 As Long
Dim i As Long
Dim s1 As String
Dim Vari() As myPGPKeyProps
Dim Idx As Integer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s1 = RtvStrPGPKeyProps(fN)
If (s1 = "") Then GoTo EXITEXIT
ReDim Vari(0 To 0)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do Until i >= Len(s1) - 1
If (Idx > 0) Then ReDim Preserve Vari(0 To Idx)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
y01 = InStr(i + 1, s1, vbTab, vbBinaryCompare)
y02 = InStr(y01 + 1, s1, vbTab, vbBinaryCompare)
y03 = InStr(y02 + 1, s1, vbTab, vbBinaryCompare)
y04 = InStr(y03 + 1, s1, vbTab, vbBinaryCompare)
y05 = InStr(y04 + 1, s1, vbTab, vbBinaryCompare)
y06 = InStr(y05 + 1, s1, vbTab, vbBinaryCompare)
y07 = InStr(y06 + 1, s1, vbTab, vbBinaryCompare)
y08 = InStr(y07 + 1, s1, vbTab, vbBinaryCompare)
y09 = InStr(y08 + 1, s1, vbTab, vbBinaryCompare)
y10 = InStr(y09 + 1, s1, vbCrLf, vbBinaryCompare)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'This test to protect Mid() is overkill and can be commented out
If ((y01 <= 0) Or _
(y02 <= 0) Or _
(y03 <= 0) Or _
(y04 <= 0) Or _
(y05 <= 0) Or _
(y06 <= 0) Or _
(y07 <= 0) Or _
(y08 <= 0) Or _
(y09 <= 0) Or _
(y10 <= 0)) Then GoTo EXITEXIT
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With Vari(Idx)
.Priv = Mid(s1, i + 1, y01 - i - 1)
.ID = Mid(s1, y01 + 1, y02 - y01 - 1)
.Adr = Mid(s1, y02 + 1, y03 - y02 - 1)
.Len = Mid(s1, y03 + 1, y04 - y03 - 1)
.Date1 = Mid(s1, y04 + 1, y05 - y04 - 1)
.Date2 = Mid(s1, y05 + 1, y06 - y05 - 1)
.FP = Mid(s1, y06 + 1, y07 - y06 - 1)
.R1 = Mid(s1, y07 + 1, y08 - y07 - 1)
.R2 = Mid(s1, y08 + 1, y09 - y08 - 1)
.Typ = Mid(s1, y09 + 1, y10 - y09 - 1)
End With
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Idx = Idx + 1
i = y10 + 1
Loop
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EXITEXIT:
RtvVariPGPKeyProps = Vari
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Function
'############################################################################################
'############################################################################################
'############################################################################################
Public Function IsPGPKeyPropsEmpty(vArray() As myPGPKeyProps) As Boolean
On Error Resume Next
Dim r As Integer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r = UBound(vArray)
If Err Then
'MsgBox Err.Number & vbCrLf & Err.Description
IsPGPKeyPropsEmpty = True
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Function
'############################################################################################
-----BEGIN PGP SIGNATURE-----
Version: N/A
iQEVAwUBPw8mxoDgT488d3zFAQHx3gf9HfGfeKgDI6WYYTI5dcEl9nRboYcATKyy
kSaWkYfBW5Th7ef5KnjIfAoEs5r7US51PcwL4gzcM0ddnf305ohJOUWIIKCAa6g4
4p/fXv94ydQI5/ZgLB7Ge9gAAt5S1IaLc6KK//hVtl3nOc06jUVWj40GkflLkfdJ
gUgK9oc2lvIalv0rXBmmUhxJfKc+olWQEM+YAIIXtBrRcwXDYy7BC4Ep6b4df0Dz
8H2uqUHlG1A9hDVLexN/LUi676rIpH/dAPER1yyc1OPPyECLfxRiQr6H8BpcIzPi
cvox4Eabz+dX42XRc0LHxZKOm0uIl1juNJIQ79K/UaWPBqAU1eMt9w==
=652X
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<MOWIN8RV37813.9632291667@Gilgamesh-frog.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!news5.aus1.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.nuthinbutnews.com!propagator2-sterling!news-in-sterling.newsfeed.com!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!nerim.net!noc.nerim.net!Gilgamesh-frogadmin.yi.org!not-for-mailReferences:
<ug3ugvchhsl8n2d3eeak0d1galve9gn4o3@4ax.com> <EFIHQP2X37813.9251967593@Gilgamesh-frog.org>Show Full Headers
Complete Article Headers
Message-ID: <MOWIN8RV37813.9632291667@Gilgamesh-frog.org> Subject: Re: spgp.dll key import function Date: Fri, 11 Jul 2003 21:07:17 +0000 From: Anonymous-Remailer@See.Comment.Header (Frog-Admin) References: <ug3ugvchhsl8n2d3eeak0d1galve9gn4o3@4ax.com> <EFIHQP2X37813.9251967593@Gilgamesh-frog.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!news5.aus1.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.nuthinbutnews.com!propagator2-sterling!news-in-sterling.newsfeed.com!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!nerim.net!noc.nerim.net!Gilgamesh-frogadmin.yi.org!not-for-mail Newsgroups: alt.privacy.anon-server Organization: Happy Lobster & Partners X-Comment: In Case of Emergency, Flush the Toilet X-Mailer: JackB.Nymble Version 2.1 Comments: This message probably did not originate from the above address. It was automatically remailed by one or more anonymous mail services. You should NEVER trust ANY address on Usenet ANYWAYS: use PGP !!! Get information about complaints from the URL below X-Remailer-Contact: http://80.65.224.85/ In case my abuse address is unreachable: It is because it has been flooded by <mgg@uiuc.edu>, please contact <abuse@uiuc.edu> Lines: 175 X-Mail2News-Contact: http://80.65.224.85/