xml.CryptoKey methods

Methods for the xml.CryptoKey class.

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

See also The Diffie-Hellman key agreement algorithm.

Table 3. Object methods: Modify
Name Description
deriveKey(
   method STRING,
   label STRING,
   seed STRING,
   created STRING,
   offset INTEGER,
   size 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(
   size 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(
   otherPubKey xml.CryptoKey,
   url STRING )
  RETURNING sharedSecret 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 of symmetric/HMAC or symmetric/encryption key type. It can be used for symmetric signature or symmetric encryption.
loadBIN(
   file STRING )
Loads a symmetric or HMAC key from a file in raw format.
loadDER(
   file 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(
   file STRING )
Loads an asymmetric DSA key, an asymmetric RSA key or Diffie-Hellman parameters from a file in PEM format.
loadPrivate(
   xml xml.DomDocument )
Loads the private asymmetric RSA key in the given XML document into the private part of this CryptoKey object, according to the XKMS2.0 specification.
loadPublic(
   xml xml.DomDocument )
Loads the public asymmetric RSA or DSA key in the given XML document into the public part of this CryptoKey object, according to the XML-Signature specification for DSA and RSA key value.
loadPublicFromString(
   pubKeyStr STRING )
Populate the current CryptoKey object with the passed public key.
savePrivate()
  RETURNING object xml.DomDocument
Saves the private part of an asymmetric RSA CryptoKey object into a XML document according to the XKMS2.0 specification.
savePublic()
  RETURNING object 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 according to the XML-Signature specification for DSA and RSA and Diffie-Hellman key values.
savePublicToString()
  RETURNING str STRING
Save the current xml.CryptoKey's public part in the returned base64 string.
saveToString()
  RETURNING str STRING
Saves the CryptoKey object into a BASE64 string format.
Table 5. Object methods: Feature
Name Description
getFeature(
   feature STRING )
  RETURNING value 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.