xml.CryptoKey methods

Methods for the xml.CryptoKey class.

Table 1. Class methods: Creation
Name Description
xml.CryptoKey.Create(
   url STRING )
  RETURNS xml.CryptoKey
Initializes a xml.CryptoKey object. Constructor of an empty CryptoKey object based on a URL.
xml.CryptoKey.CreateDerivedKey(
   url STRING )
  RETURNS xml.CryptoKey
Constructor of an empty CryptoKey object based on a URL. The crypto key must be derived before use.
xml.CryptoKey.CreateFromNode(
   url STRING,
   node xml.DomNode )
  RETURNS xml.CryptoKey
Constructor of a new CryptoKey object based on a URL, from a XML node based on the XML-Signature and XML-Encryption specification.
Table 2. Object methods: Access
Name Description
compareTo(
   toCompare xml.CryptoKey )
  RETURNS INTEGER
Compares a CryptoKey object to a second key.
getSHA1()
  RETURNS STRING
Returns the SHA1 encoded key identifier in a base64 encoded STRING.
getSize()
  RETURNS INTEGER
Returns the size of the key in bits.
getType()
  RETURNS STRING
Returns the type of key.
getUsage()
  RETURNS STRING
Returns the usage of the key.
getUrl()
  RETURNS STRING
Returns the key identifier as a URL.

See also The Diffie-Hellman key agreement algorithm.

Table 3. Object methods: Modify
Name Description
deriveKey(
   url STRING,
   label STRING,
   seed STRING,
   created STRING,
   offset INTEGER,
   bytes INTEGER )
Derives the symmetric or HMAC CryptoKey object using the given method identifier and concatenating the optional label, the mandatory seed value and the optional created date as initial random value.
generateKey(
   keySize INTEGER )
Generates a random key of given size (in bits).
setKey(
   key STRING )
Defines the value of a HMAC or Symmetric key.
Table 4. Object methods: Load, save, and compute
Name Description
computeKey(
   pub xml.CryptoKey,
   url STRING )
  RETURNS xml.CryptoKey
Computes the shared secret based on the given modulus, generator, the private key, and the other peer's public key. The returned key can be any symmetric/HMAC or symmetric/encryption key type. It can be used for symmetric signature or symmetric encryption.
loadBIN(
   filename STRING )
Loads a symmetric or HMAC key from a file in raw format.
loadDER(
   filename STRING )
Loads an asymmetric DSA key, an asymmetric RSA key, or Diffie-Hellman parameters from a file in DER format.
loadFromString(
   str STRING )
Loads the given key in BASE64 string format into a CryptoKey object.
loadPEM(
   filename STRING )
Loads an asymmetric DSA key, an asymmetric RSA key, or Diffie-Hellman parameters from a file in PEM format.
loadPrivate(
   doc xml.DomDocument )
Loads the private asymmetric RSA key from the given XML document.
loadPublic(
   doc xml.DomDocument )
Loads the public part of an asymmetric RSA or DSA CryptoKey object, or the parameters and the public key of the Diffie-Hellman object from a XML document.
loadPublicFromString(
   str STRING )
Populate the current CryptoKey object with the passed public key.
savePrivate()
  RETURNS xml.DomDocument
Saves the private key part of an asymmetric RSA CryptoKey object into a XML document according to the XKMS2.0 specification.
savePublic()
  RETURNS xml.DomDocument
Saves the public part of an asymmetric RSA or DSA CryptoKey object, or the parameters and the public key of the Diffie-Hellman object into a XML document.
savePublicToString()
  RETURNS STRING
Save the current xml.CryptoKey's public part in the returned base64 string.
saveToString()
  RETURNS STRING
Saves the CryptoKey object into a BASE64 string format.
Table 5. Object methods: Feature
Name Description
getFeature(
   feature STRING )
  RETURNS STRING
Returns the value of the given feature for this CryptoKey object, or NULL.
setFeature(
   feature STRING,
   value STRING )
Sets or resets the value of a feature for a CryptoKey object.