Repository navigation
IKeyBase
#include <certpp/crypto/keys.hpp> --- certpp::crypto
Common interface for symmetric and asymmetric cryptographic keys: every key has a size and can be serialized to bytes. IPublicKey/IPrivateKey extend this for the asymmetric case; a future symmetric key interface would extend it the same way.
Virtual destructor.
Serializes this key to its algorithm-defined byte encoding.
-
out--- The buffer to receive the serialized key.
Returns: ERET_OK on success; another ERetCode describing the failure otherwise.
Compares this key with another key.
-
other--- The other key to compare with.
Returns: A negative value if this is less than other, zero if equal, positive if greater.
Serializes a key and compares it with another through the base both key families share. compare() answers "the same bytes", which is a different question from "do these two form a pair" -- that one needs a signature, as CCertCollection::checkKeyPairing() does.
// given: const crypto::IKeyBasePtr& key, const crypto::IKeyBasePtr& other
COctet encoded;
if (key->serialize(encoded) != ERET_OK || encoded.empty()) {
return;
}
if (key->compare(other) != 0) {
return; // different key material
}
// encoded is the algorithm-defined encoding, ready to go into a SubjectPublicKeyInfo or a
// private-key file.Reference generated from certpp/crypto/keys.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.