On Wednesday, October 14, 2015 at 3:28:04 PM UTC-4, Andrés Garagiola wrote:
>
> Anyone could pass me an example that explain how get the format (ASN) and 
> the algorithm name from a PrivateKey and from a PublicKey?
>

OK, so there's two different concepts going on here (if I am parsing things 
correctly). First is standard algorithm names. The name depends on the 
standard body you are using. Luckily, most names are consistent across 
domains.

Sometimes, there is no standard name. For example, from eccrypto.h:

    static std::string CRYPTOPP_API StaticAlgorithmName()
        {return "ECIES";}    // TODO: fix this after name is standardized

The second concept appears to be identification of keys. For this, an OID 
is usually used. Like with names, it depends on the standard body, but they 
are mostly consistent.

As an example consider the following in ASN1 notation:

    RSAPublicKey := SEQUENCE {
        modulus   INTEGER
        exponent  INTEGER
    }

That's "just" a RSA public key in a presentation format (the ASN.1 
encoding). OpenSSL calls this a "public key" (non-traditional). If you 
looked at the PEM encoding, it would look something like:

    ----- BEGIN RSA PUBLIC KEY -----
    ....
    ----- END RSA PUBLIC KEY -----

If one adds the OID/algorithm identifier, then we would have:

    PublicKeyInfo ::= SEQUENCE {
        algorithm        AlgorithmIdentifier,
        publicKey       BITSTRING
    }

The "publicKey BITSTRING" is the same as the "RSAPublicKey := SEQUENCE", 
but its a bit string rather than a sequence.

OpenSSL calls this a "traditional" public key, but its usually known as a 
"subjectPublicKeyInfo" or SPKI. The PEM would look as:

    ----- BEGIN PUBLIC KEY -----
    ....
    ----- END PUBLIC KEY -----

There's no need for the "BEGIN RSA PUBLIC KEY" because the OID encodes it.

Jeff

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to