Interface EncryptLicense


public interface EncryptLicense
Encrypt and decrypt license text. The license text is encrypted by AES using an internally generated random key. The AES key is encrypted by RSA and is added to the encrypted license text. The encrypted license text looks like:
 ELO DIGITAL OFFICE GMBH ENCRYPTED LICENSE --- fix header followed by some comment lines
 createDate=2021-07-02
 expirationDate=2022-07-31
 product=20e
 customer=ELO 20 Test Not for resale
 hash=506e679fa27fc701693986869c4592e6195a3d17115c2ee559685c0fe5c64a15
 
 SqZVF2SPZfX9LX0sjo9Po4CkD4r3gjNDw5ItpDIyK4dU6Dsf3FEcUPHGbuOznjLXUZscn8iunj3W+tQOVqcSlBhjcgNWUqECCceB
 7KR+cK22IgQDbtEdaVjmIoqxbCjPDdOjOzpR56eN6emaxxRCp4Hi+N85XO2UYrw/5ZaiyVcyzOuVM7vWcGH0e0yf5y98j3uYDant
 dOo3ZcJHsknpjr6o5lTHaUWilMCBiH6/1FW/YkAZQxsKQ6aigVwsoPMvvmZM98FnBhP4zfJSDfh/YahappwS+W2S4tRtqpK1g5+f
 lzBmufY6X81mTFP8GfTQPZLK++MtCnDDqt17HFz7+g==  --- encrypted AES key
 
 Nw/r4OFzm7j6bFwqUiyaTnHYd5qT0ZVnY8CzxzGylecavjxSfZG5FzZNMputLsfplANeAf1KxbRRwsqQnFfr6b/S1juBcb63tiKT
 MnsxFtVtJ76FbFA6WLvsI49OR0kNDEJlBSCcXu5yKvMuKymbq7Jg7XTqkWcEfDkKHwMyE6/tGbmmpEkGXOV4QdrLdNy4oROA8vTF
 ebjJJsdvKlYEY18dWOrT0whyRpL/Uzh/KqLlKRDEaiOZNFiTupNNo95nOCq7vrCzsu296Ylz7Wsys/X6mVAV51K9tRrZahjMcOES
 D6sthVzJYzTlqeIJ4ONrQG7yYFXHWTy3wdqOVrbIsISzmh7//kepvq+X+RbHB/Tl2ZWXOacSL5+5t5bwTxNQ4ILJf9/OE9yf2ilO
 xqYXFPYkJisuJynyjdBXlmVaVja9euyegKk/WqhY21CJnAPy+qnU6oC7eV1lRgO58FsJz/sL1qXhTtfrxfa+3WDzF3riTs5QjPDL
 GHGicIVuZnlz   --- encrypted license content
 
 2+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAos+/v9EzdvvE42YZL1H65+0uwDPW5l1RI2n0hZqvkZwkzpq2lctujl
 LtwaXeSgvL66SbYJuxIy7S4ZA/aTP4UVEtqVPKYNatgiE+N6lBw/CVu94MWpW99eDmuLU9uM7gN+mJDdDz2tHyrW6Z3KeHn1cMOA
 87pJgG9tSQaIRN7KQjd+wZUMUbUhk18vnO/tVUZQTa24nklF3ItMTjjFnAXKQnnemP9xqm3ekKnwcjOiQmGRWn6j01jwU9PcajnD
 QuQdJx8WQaggQl7OJcGHeFl46x8rHG0or7i81dHuXhHzXk4qAze7Kg7j90ki2d1CmQc7xzqtVOQUghFr9adlsrlQIDAQAB   
 --- public license key 
 
For decryption, the entire text has to be passed along with the private RSA key. Function generateKeysRSA() can be used to create a RSA key pair. To encrypt a license, call encrypt(PublicKey, String). To decrypt an encrypted license call decrypt(PrivateKey, String). EIX-2598
  • Field Details

    • VERSION_WITH_PUBLIC_KEY

      static final int VERSION_WITH_PUBLIC_KEY
      Include public key in encrypted license text. EIX-3641
      See Also:
    • VERSION_RSA_WITH_PADDING

      static final int VERSION_RSA_WITH_PADDING
      Use RSA with padding. EIX-2781
      See Also:
    • CURRENT_VERSION

      static final int CURRENT_VERSION
      Current version.
      See Also:
    • VERSION

      static final String VERSION
      Encrypted license version. EIX-3641
      See Also:
    • SORDGUID

      static final String SORDGUID
      Reference to license repository. EIX-3641
      See Also:
    • PRODUCT

      static final String PRODUCT
      Product name. EIX-3641
      See Also:
    • EXPIRATION_DATE

      static final String EXPIRATION_DATE
      License expiration date. EIX-3641
      See Also:
    • CREATE_DATE

      static final String CREATE_DATE
      License creation date. EIX-3641
      See Also:
    • LICENSE_SERVER_ADDRESS

      static final String LICENSE_SERVER_ADDRESS
      Address of the license server. Used as primary server address since 23.00.001. EIX-3641
      See Also:
    • LICENSE_SERVER_ADDRESS_FALLBACK

      static final String LICENSE_SERVER_ADDRESS_FALLBACK
      Address of the old license server. Used as primary server address for versions up to 23.00.000.
      See Also:
    • LICENSE_SERVER_URL

      static final String LICENSE_SERVER_URL
      URL for downloading licenses. EIX-3632: Preferred URL for connecting to the license server (since 23.00.001). If the license is not available at this address, the license is downloaded from LICENSE_SERVER_URL_FALLBACK.
      See Also:
    • LICENSE_SERVER_URL_FALLBACK

      static final String LICENSE_SERVER_URL_FALLBACK
      Old URL for downloading licenses. EIX-3632: Fallback URL for connecting to the license server. Versions up to 23.00.000 call only this URL.
      See Also:
  • Method Details

    • getInstance

      static EncryptLicense getInstance()
      Get instance to access the functions.
      Returns:
      Instance
    • encrypt

      String encrypt(PublicKey publicKey, String licenseText)
      Encrypt license text.
      Parameters:
      publicKey - Public RSA key
      licenseText - License file content
      Returns:
      Encrypted license data
    • decrypt

      String decrypt(PrivateKey privateKey, String encryptedText)
      Decrypt license data.
      Parameters:
      privateKey - Private RSA key
      encryptedText - Encrypted license data
      Returns:
      License file content
    • parse

      EncryptLicense.Data parse(String encryptedText)
      Get properties from encrypted license. EIX-3641 See VERSION and others.
      Parameters:
      encryptedText - Encrypted license text
      Returns:
      Properties
    • keyToString

      String keyToString(PublicKey publicKey)
      Serialize a public RSA key to string.
      Parameters:
      publicKey - Public RSA key
      Returns:
      String
    • keyToString

      String keyToString(PrivateKey privateKey)
      Serialize a private RSA key to string.
      Parameters:
      privateKey - Private RSA key
      Returns:
      String
    • publicKeyFromString

      PublicKey publicKeyFromString(String str)
      Decode the string representation of a public RSA key.
      Parameters:
      str - String representation
      Returns:
      Key object
    • privateKeyFromString

      PrivateKey privateKeyFromString(String str)
      Decode the string representation of a private RSA key.
      Parameters:
      str - String representation
      Returns:
      Key object
    • getPublicKey

      PublicKey getPublicKey(PrivateKey privateKey)
      Extract a public key from a given private key.
      Parameters:
      privateKey - Private RSA key
      Returns:
      Public RSA key
    • getRemoteLicenseAddress

      String getRemoteLicenseAddress(String serverAddress, PublicKey publicKey)
      Get license remote URL. URL from where the encrypted license can be downloaded. The URL contains a hash value that identifies the license. The hash value is built based on the public key. In order to get only the hash value, call this function with an empty serverAddress.
      Parameters:
      serverAddress - URL to license server, usually LICENSE_SERVER_URL or empty to get the license ID.
      publicKey - Public RSA key or null to get the download path.
      Returns:
      URL
    • isLicenseEncryptionKey

      boolean isLicenseEncryptionKey(String licenseText)
      Return true, if the given text is an encryption key.
      Parameters:
      licenseText - Maybe encrypted key
      Returns:
      true, if encryption key
    • generateKeysRSA

      KeyPair generateKeysRSA()
      Generate RSA key pair.
      Returns:
      RSA keys
    • sign

      String sign(PrivateKey privateKey, String data)
      Compute signature of given data. EIX-3641
      Parameters:
      privateKey - Private key
      data - Data to be signed
      Returns:
      Signature
    • verify

      boolean verify(PublicKey publicKey, String data, String signature)
      Verify signature. EIX-3641
      Parameters:
      publicKey - Public key
      data - Data
      signature - Signature of data
      Returns:
      true, if signature is valid