API routine CryptEncrypt() returns error 234 
Author Message
 API routine CryptEncrypt() returns error 234

Hello All,

We are trying to use the CryptEncrypt() API routine to encode a text
string.  We have this working in a Visual Basic program and are now
trying to port it to a fortran program.

In our program we call the CryptEncrypt() API routine twice.  The first
time we want to send a null or blank string along with the current clear
text string length to get back the encoded string length.  We can then
check if our output string will be long enough to contain the encoded
string.

When we call the CryptEncrypt() routine the first time in the Fortran
program we get an error code of 234.  That error translates to "More
data is available" or ERROR_MORE_DATA.  I'm not sure how to interpret
that error code.
I think we have a problem with defining the null string to pass in; we
have tried several options including the pointer to a blank string,
NULL, a zero "0" that all return the same error code 234.

I appreciate your comments and advice on how we can use the
CryptEncrypt() routine to encode a text string from a Fortran program.

Thanks for your help!

Regards,

Greg Thorwald
Structural Reliability Technology
1898 South Flatiron Court, Suite 235
Boulder, Colorado  80301
voice:  (303) 415-1475   FAX:  (303) 415-1847



Sun, 09 Nov 2003 22:48:17 GMT  
 API routine CryptEncrypt() returns error 234
From the Win API point of view, a null string is a string containing only a
null terminator (\0). I haven't check the CryptEncrypt() API, so I don't
know what the null string is used for, but none of the methods you mentioned
is passing a C-style null string. The following (or a variant of it) will
work:

Pass a pointer to an integer variable that has been set to zero, i.e.:

integer::i
i=0 !not really necessary in most compilers
!call your API with loc(i) as the null string argument.

best regards,

--
Marco A. Garcia
Canaima Software
P.O. Box 13162
La Jolla, CA. 92039
U.S.A.

Tel/Fax: (619) 233-6831
http://www.canaimasoft.com
Developers of f90SQL the Database Connectivity Solution for Fortran, and
f90VB the library for seamless Fortran-VB and Fortran-OLE Automation
integration


Quote:
> Hello All,

> We are trying to use the CryptEncrypt() API routine to encode a text
> string.  We have this working in a Visual Basic program and are now
> trying to port it to a Fortran program.

> In our program we call the CryptEncrypt() API routine twice.  The first
> time we want to send a null or blank string along with the current clear
> text string length to get back the encoded string length.  We can then
> check if our output string will be long enough to contain the encoded
> string.

> When we call the CryptEncrypt() routine the first time in the Fortran
> program we get an error code of 234.  That error translates to "More
> data is available" or ERROR_MORE_DATA.  I'm not sure how to interpret
> that error code.
> I think we have a problem with defining the null string to pass in; we
> have tried several options including the pointer to a blank string,
> NULL, a zero "0" that all return the same error code 234.

> I appreciate your comments and advice on how we can use the
> CryptEncrypt() routine to encode a text string from a Fortran program.

> Thanks for your help!

> Regards,

> Greg Thorwald
> Structural Reliability Technology
> 1898 South Flatiron Court, Suite 235
> Boulder, Colorado  80301
> voice:  (303) 415-1475   FAX:  (303) 415-1847




Mon, 10 Nov 2003 01:54:05 GMT  
 API routine CryptEncrypt() returns error 234
How does this work?  loc(i) is not null, it is some (probably) 4-byte
quantity that could take any value.

Quote:

> From the Win API point of view, a null string is a string containing only a
> null terminator (\0). I haven't check the CryptEncrypt() API, so I don't
> know what the null string is used for, but none of the methods you mentioned
> is passing a C-style null string. The following (or a variant of it) will
> work:

> Pass a pointer to an integer variable that has been set to zero, i.e.:

> integer::i
> i=0 !not really necessary in most compilers
> !call your API with loc(i) as the null string argument.

> best regards,

> --
> Marco A. Garcia
> Canaima Software
> P.O. Box 13162
> La Jolla, CA. 92039
> U.S.A.

> Tel/Fax: (619) 233-6831
> http://www.canaimasoft.com
> Developers of f90SQL the Database Connectivity Solution for Fortran, and
> f90VB the library for seamless Fortran-VB and Fortran-OLE Automation
> integration



> > Hello All,

> > We are trying to use the CryptEncrypt() API routine to encode a text
> > string.  We have this working in a Visual Basic program and are now
> > trying to port it to a Fortran program.

> > In our program we call the CryptEncrypt() API routine twice.  The first
> > time we want to send a null or blank string along with the current clear
> > text string length to get back the encoded string length.  We can then
> > check if our output string will be long enough to contain the encoded
> > string.

> > When we call the CryptEncrypt() routine the first time in the Fortran
> > program we get an error code of 234.  That error translates to "More
> > data is available" or ERROR_MORE_DATA.  I'm not sure how to interpret
> > that error code.
> > I think we have a problem with defining the null string to pass in; we
> > have tried several options including the pointer to a blank string,
> > NULL, a zero "0" that all return the same error code 234.

> > I appreciate your comments and advice on how we can use the
> > CryptEncrypt() routine to encode a text string from a Fortran program.

> > Thanks for your help!

> > Regards,

> > Greg Thorwald
> > Structural Reliability Technology
> > 1898 South Flatiron Court, Suite 235
> > Boulder, Colorado  80301
> > voice:  (303) 415-1475   FAX:  (303) 415-1847


--
--------------------------------------------

1/44 Arthur St         Tel: (64-9) 525-6878
Ellerslie, N.Z.        Fax: (64-9) 525-6878
--------------------------------------------


Mon, 10 Nov 2003 04:16:04 GMT  
 API routine CryptEncrypt() returns error 234


| Hello All,
|
| We are trying to use the CryptEncrypt() API routine to encode a text
| string.  We have this working in a Visual Basic program and are now
| trying to port it to a Fortran program.
|
| In our program we call the CryptEncrypt() API routine twice.  The first
| time we want to send a null or blank string along with the current clear
| text string length to get back the encoded string length.  We can then
| check if our output string will be long enough to contain the encoded
| string.

| When we call the CryptEncrypt() routine the first time in the Fortran
| program we get an error code of 234.  That error translates to "More
| data is available" or ERROR_MORE_DATA.  I'm not sure how to interpret
| that error code.
| I think we have a problem with defining the null string to pass in; we
| have tried several options including the pointer to a blank string,
| NULL, a zero "0" that all return the same error code 234.
|
| I appreciate your comments and advice on how we can use the
| CryptEncrypt() routine to encode a text string from a Fortran program.
|
| Thanks for your help!
|
| Regards,

You didn't mention your compiler, so I'll give you CVF solution;
with other compilers with Win32 API support it should be similar.
My CVF version does not have CryptEncrypt declared anywhere
(it's probably in in newer versions).

When there's a pointer to "string" or "buffer" involved in an
API call, CVF headers typically translate that as a CHARACTER*(*)
by reference. When a NULL argument means something in that
context, you should pass NULL_CHAR, which is actually a NULLIFYed
POINTER to a CHARACTER (alternatively, there's also %val(0)
in CVF6.1 up).
As for pointers to integers (in/out) -- like pdwDataLen argument --
CVF is typically not consistent, so there's usually INTEGER but
not by REFERENCE but by VALUE; thus, you should pass LOC(integer).
So, I bet that correct order is something like:

CHARACTER(LEN=something):: sBuffer
bStatus=CryptEncrypt(hKey, hHash, .FALSE., 0, NULL_CHAR,    &
        LOC(nBytes), 0)
bStatus=CryptEncrypt(hKey, hHash, bSomething, 0, sBuffer,   &
        LOC(nBytes), LEN(sBuffer))

Please take a look on actual INTERFACE block for CryptEncrypt
in Win32 headers (do a "Find in files" on ...\DF\Include).
As I said, my guess is that it's:

!DEC$ATTRIBUTES REFERENCE:: pbData
CHARACTER(LEN=*) pbData
INTEGER pdwDataLen

As for ERROR_MORE_DATA, docs say that:

"If the buffer specified by pbData is not large enough to
hold the data, the function returns the ERROR_MORE_DATA
error code (through GetLastError) and stores the required buffer
size, in bytes, into the variable pointed to by pdwDataLen"

HTH
Jugoslav



Mon, 10 Nov 2003 16:32:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Jun for Java 234

2. PEP 234: Iterators

3. PEP 234: Iterators

4. PEP 234: Iterators

5. PEP 234: Iterators (fwd)

6. Discussion about PEP 234: iterators

7. PEP 234 little bug?

8. PEP 234: Iterators (fwd)

9. Serial Communication (API-calls) and possible error in CW API-Viewer

10. passing an LPCSTR or LPCTSTR string to an API routine, CryptAcquireContext()

11. Lf95: How to call API file mapping routines?

12. how to get error line information when TCL_EvalFile return error

 

 
Powered by phpBB® Forum Software