Couple of questions re: attributes

View: New views
6 Messages — Rating Filter:   Alert me  

Couple of questions re: attributes

by Miller, Timothy J. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, I'm new at cryptlib, so bear with me.

First:  When setting a salt on a context, what is expected in the
string?  I.e., in the Python bindings if I do:

cryptSetAttributeString(context, CRYPT_CTXINFO_KEYING_SALT, salt)

When salt is a packed string (i.e., bytestring) or an arbitrary string,
I get a bad argument error.  *Some* uppercase hex strings are accepted,
some aren't (e.g., '7D60435F02E9E0AE' works, '1234567890ABCDEF'
doesn't).  What's the criteria and is this documented somewhere?  I
can't find a mention in the docs.

Second:  When setting a password on a context I'm getting an internal
consistency check raised.  Clearly I'm in the wrong here, but it looks
right to me.  E.g. (again in Python):

 >>> from cryptlib_py import *
 >>> salt = '7D60435F02E9E0AE'
 >>> ctx = cryptCreateContext(CRYPT_UNUSED, CRYPT_ALGO_DES)
 >>> cryptSetAttribute(ctx, CRYPT_CTXINFO_KEYSIZE, 8)
 >>> cryptSetAttribute(ctx, CRYPY_KEYING_ITERATIONS, 800)
 >>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_SALT, salt)
 >>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_VALUE, 'password')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
cryptlib_py.CryptException: (-16, 'Internal consistency check failed')

Interestingly, other values of the password value can yield a bad
argument error.  E.g.:

 >>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_VALUE, 'Cv(G%$Va')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
cryptlib_py.CryptException: (-3, 'Bad argument, parameter 3')

Any help is always appreciated.  (FWIW all I'm doing is trying to
validate some test vectors as a way to familiarize myself with cryptlib.
  Real work comes later. ;)

-- Tim


_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

smime.p7s (4K) Download Attachment

Parent Message unknown Re: Couple of questions re: attributes

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Timothy J. Miller" <tmiller@...> writes:

>First:  When setting a salt on a context, what is expected in the string?
>I.e., in the Python bindings if I do:
>
>cryptSetAttributeString(context, CRYPT_CTXINFO_KEYING_SALT, salt)
>
>When salt is a packed string (i.e., bytestring) or an arbitrary string, I get
>a bad argument error.  *Some* uppercase hex strings are accepted, some aren't
>(e.g., '7D60435F02E9E0AE' works, '1234567890ABCDEF' doesn't).  What's the
>criteria and is this documented somewhere?  I can't find a mention in the
>docs.

At the native API level it should be binary data, however I'm not sure what
Python's marshalling does when it passes the data to the native API, perhaps
someone else can answer this.

>Second:  When setting a password on a context I'm getting an internal
>consistency check raised.  Clearly I'm in the wrong here, but it looks right
>to me.  E.g. (again in Python):
>
>>> from cryptlib_py import *
>>> salt = '7D60435F02E9E0AE'
>>> ctx = cryptCreateContext(CRYPT_UNUSED, CRYPT_ALGO_DES)
>>> cryptSetAttribute(ctx, CRYPT_CTXINFO_KEYSIZE, 8)
>>> cryptSetAttribute(ctx, CRYPY_KEYING_ITERATIONS, 800)
>>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_SALT, salt)
>>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_VALUE, 'password')
>Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>cryptlib_py.CryptException: (-16, 'Internal consistency check failed')

Hmm, can you provide details of what gets passed to the native API to trigger
this?  Or can you build the debug version of the code, which will throw an
exception for the check indicating where it's being done?

Peter.

_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

Re: Couple of questions re: attributes

by Miller, Timothy J. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter Gutmann wrote:

> At the native API level it should be binary data, however I'm not sure whatz
> Python's marshalling does when it passes the data to the native API, perhaps
> someone else can answer this.

As near as I can tell it's using the old C embedding/extension
protocols.  It's a direct conversion of a Python str into a C char*
using the PyObject_AsCharBuffer() call.

http://docs.python.org/c-api/objbuffer.html

Who's the maintainer of this binding?  Is there one?  It could use
updating, even for 2.6, and I doubt it will work under 3.0.

>>>> cryptSetAttributeString(ctx, CRYPT_CTXINFO_KEYING_VALUE, 'password')
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>> cryptlib_py.CryptException: (-16, 'Internal consistency check failed')

> Hmm, can you provide details of what gets passed to the native API to trigger
> this?  Or can you build the debug version of the code, which will throw an
> exception for the check indicating where it's being done?

When I retry with a debug build I get (-3, 'Bad argument, parameter 3')
instead.  As near as I can tell the Python binding doesn't pass on
anything else.  I can try to skip the binding and call to cryptlib
directly using ctypes.

-- Tim




_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

smime.p7s (4K) Download Attachment

Re: Couple of questions re: attributes

by Miller, Timothy J. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Timothy J. Miller wrote:

> When I retry with a debug build I get (-3, 'Bad argument, parameter 3')
> instead.  As near as I can tell the Python binding doesn't pass on
> anything else.  I can try to skip the binding and call to cryptlib
> directly using ctypes.

Amend that.  I forgot to install the dang sharedlib prior to rebuilding
the cryptlib_py binding.

Now the module load, but aborts on cryptInit():

 >>> from cryptlib_py import *
 >>> cryptInit()
python: device/system.c:788: setDeviceSystem: Assertion `( ( deviceInfo
) != ((void *)0) && ( void * ) ( deviceInfo ) > ( void * ) &_etext && (
sizeof( DEVICE_INFO ) ) > 0 )' failed.
Aborted.

Methinks I'mna hafta either drop python or drop cryptlib since I don't
have a lot of work time to commit to this, either of which is a shame.

-- Tim



_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

smime.p7s (4K) Download Attachment

Re: Couple of questions re: attributes

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Timothy J. Miller" <tmiller@...> writes:

>Who's the maintainer of this binding?  Is there one?  It could use updating,
>even for 2.6, and I doubt it will work under 3.0.

Yeah, the 2.x -> 3 transition was a bit of a headache... unfortunately the
person who created the Python script has been a bit busy with other work for
awhile, another person (I'm avoiding names so there's no finger-pointing at
anyone) who did the Delphi/VB/etc scripts was kind enough to have a look at
the Python one, but if there are any Python users on the list it'd be nice to
get someone to give it a once-over to fix it up for 3.0 and resolve any other
minor issues.

>I can try to skip the binding and call to cryptlib directly using ctypes.

That would be useful, or even just anything where I can see what's being
passed to the C code so I can reproduce the problem.

Peter.

_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

Re: Couple of questions re: attributes

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Timothy J. Miller" <tmiller@...> writes:

>python: device/system.c:788: setDeviceSystem: Assertion `( ( deviceInfo ) !=
>((void *)0) && ( void * ) ( deviceInfo ) > ( void * ) &_etext && ( sizeof(
>DEVICE_INFO ) ) > 0 )' failed.
>Aborted.

Ah, damn, I forgot about that, that's triggering a gcc compiler bug when you
enable debug mode (there are checks in the code for this, and that's one of
them being triggered).

>Methinks I'mna hafta either drop python or drop cryptlib since I don't have a
>lot of work time to commit to this, either of which is a shame.

Well, I'd try at least the C interface, and see if anyone responds to the
request for help with the Python script.

I can also prepare a slightly newer release for you that resolves the
(identified :-) issues you've had if you like.

Peter.

_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.