How to determine Keyset algorithm

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

How to determine Keyset algorithm

by Crypt lib :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a group of previously generated keysets. I have to share the public keys with arbitrary 3rd parties who demand specific key formats, I get *NO* choice here. I also have multiple keysets in the app of various algorithms, the 3rd party demands the algorithm I must use, I get no choice here.

End result is a file with lots of keysets, of different algorithms, within a single application.

I'm writing a generic export function which exports the requested file format cases as I run into them. However when I select the keyset I have no idea how to determine it's algorithm after creation so as to properly create the PEM/BASE64 wrappers and headers for the various requested cases. I see there are keyset query operations but I don't see how I determine a keysets algorithm details. Perhaps I must manage this seperately on my own? Or is there a way to query the keysets algorithm details? If so how do I do this?

TIA

_______________________________________________
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: How to determine Keyset algorithm

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Crypt lib" <cryptlib@...> writes:

>I'm writing a generic export function which exports the requested file format
>cases as I run into them. However when I select the keyset I have no idea how
>to determine it's algorithm after creation so as to properly create the
>PEM/BASE64 wrappers and headers for the various requested cases.

When you say "algorithm" I assume you mean the algorithm of an individual
public key stored within the keyset, to get this you read the
CRYPT_CTXINFO_ALGO attribute from the key when it's been retrieved from the
keyset into a context.

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: How to determine Keyset algorithm

by Crypt lib :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You assumptions are correct. :)

CreateContext() requires me to specify an algorithm, "CRYPT_ALGO_NONE" throws an error.

It does appear if I just "guess" (just spec something), it does seem to work even if the creation specs do not match the loaded keyset. That is no error is thrown when loading a key that does not match the spec for the created context.

Please confirm that it's acceptable to enter a "bogus" algorithm value, and use it fearlessly when loading an arbitrary / totally unknown, keyset.

Thanks!




On 10/21/08, Peter Gutmann <pgut001@...> wrote:
"Crypt lib" <cryptlib@...> writes:

>I'm writing a generic export function which exports the requested file format
>cases as I run into them. However when I select the keyset I have no idea how
>to determine it's algorithm after creation so as to properly create the
>PEM/BASE64 wrappers and headers for the various requested cases.


When you say "algorithm" I assume you mean the algorithm of an individual
public key stored within the keyset, to get this you read the
CRYPT_CTXINFO_ALGO attribute from the key when it's been retrieved from the
keyset into a context.


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: How to determine Keyset algorithm

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Crypt lib" <cryptlib@...> writes:

>CreateContext() requires me to specify an algorithm, "CRYPT_ALGO_NONE" throws
>an error.
>
>It does appear if I just "guess" (just spec something), it does seem to work
>even if the creation specs do not match the loaded keyset. That is no error
>is thrown when loading a key that does not match the spec for the created
>context.
>
>Please confirm that it's acceptable to enter a "bogus" algorithm value, and
>use it fearlessly when loading an arbitrary / totally unknown, keyset.

Uhh, where do you need to specify an algorithm when you retrive a key?  You
just call cryptGetPublic/PrivateKey() and the algorithm information is set up
based on what's in the keyset.

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: How to determine Keyset algorithm

by Crypt lib :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It was my understinding that I had to use cryptCreateContext() to create the context as the target for cryptGetPublicKey() into which the needed values where place.

I did not know cryptGetPublicKey() created the context and instaintiated its values associated with the key.

I see just commenting out the cryptCreateContext() results in the code working fine and the problem I stated in effect goes away.

Thanks!


On 10/22/08, Peter Gutmann <pgut001@...> wrote:
"Crypt lib" <cryptlib@...> writes:


>CreateContext() requires me to specify an algorithm, "CRYPT_ALGO_NONE" throws
>an error.
>
>It does appear if I just "guess" (just spec something), it does seem to work
>even if the creation specs do not match the loaded keyset. That is no error
>is thrown when loading a key that does not match the spec for the created
>context.
>
>Please confirm that it's acceptable to enter a "bogus" algorithm value, and
>use it fearlessly when loading an arbitrary / totally unknown, keyset.


Uhh, where do you need to specify an algorithm when you retrive a key?  You
just call cryptGetPublic/PrivateKey() and the algorithm information is set up
based on what's in the keyset.


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.