Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Invoke-JS7Decrypt

SYNOPSIS

Encrypts Decrypts a value or file using an X.509 Certificate or Public Private Key

SYNTAX

Invoke-JS7Decrypt [-Value] <String> [[-File] <String>] [[-OutFile] <String>] [[-Key] <X509Certificate2>] [[-KeyPath] <String>] [[-KeyPasswordKeyCredential] <PSCredential>] [[-JavaHome] <String>] [-JavaLib] <String> [[-JavaOptions] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

The cmdlet encrypts strings, numbers and files using decrypts results of a previous, asymmetric encryption,
for details see https://kb.sos-berlin.com/display/JS7/JS7+-+Encryption+and+Decryption

...

-Value <String>
Specifies the value that should be encrypted.
Only one of the parameters -Value or -File can be used. result that was returned by previous encryption. The result includes the following elements separated by spaces:

* encrypted symmetric key
* initialization vector
* encrypted secret or path to encrypted file

Required?true
Position?1
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

...

-File <String>
Specifies the location of a input the encrypted file that should be encrypted.
Only one of the parameters -Value or -File can be useddecrypted.

Required?false
Position?2
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

...

-OutFile <String>
Specifies the location of the encrypted decrypted output file that should be created if the -File parameter is used.

If the output file exists, then it will be overwritten.

...

Key

-Key <X509Certificate2>
Specifies the X.509 Certificate object holding the Private Key that should be used to decrypt an encrypted value or file.

Certificate objects can be retrieved from a Windows certificate store using the Certificate's thumbprint like this:
$cert = Get-ChildItem cert:\CurrentUser\my | Where { $_.Thumbprint -eq '2B03EA68F103E80D83228ABCF88A3B448CC8B257' }

Only one of the parameters -Key or -KeyPath can be used.

Decryption requires use of the -JavaLib parameter that points to the location of JS7 encryption libraries.

Required?false
Position?4
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

KeyPath

-KeyPath <String>
Specifies the location of the Private Key file that is required to decrypt an encrypted value or file.

Only one of the parameters -Key or -KeyPath can be used.

Decryption requires use of the -JavaLib parameter that points to the location of JS7 encryption libraries.

Required?false
Position?5
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

...

KeyCredential

-KeyPassword <PSCredential>
KeyCredential <PSCredential>
Specifies a credential object holding the password that is optionally used to protect the Private Key.
The password can be specified from a credential object in a number of ways, for example

$credential = (New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'key', ( 'jobscheduler' | ConvertTo-SecureString -AsPlainText -Force))

The 'key' credential name can be chosen arbitrarily, the 'jobscheduler' password as added to the credential object from a Secure String.

Required?false
Position?6
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

...

-JavaHome <String>
Specifies the location to which Java is installed. Java is required to encrypt decrypt values or files.
If the parameter is not specified then Java will be used from the value of the JAVA_HOME or PATH environment variables.

...

-JavaLib <String>
Specifies the location of the JS7 encryption libraries.

The libraries ship with Agents and are available from the Agent's <agent-home>/lib directory. For encryption decryption outside of JS7 products the JS7 encryption libraries are available for download.

...

-JavaOptions <String>
Specifies the Java options used when invoking Java for encryption decryption using the -EncryptCertificatePath Key or -EncryptCertificate KeyPath parameters.
Java options can be used for example to limit memory usage as with -JavaOptions "-Xmx32m".

...

PS > Invoke-JS7Decrypt -Value $result -KeyPath C:\js7\js7.encryption\agent.key -KeyPassword KeyCredential (New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'key', ( 'jobscheduler' | ConvertTo-SecureString -AsPlainText -Force)) -JavaLib C:\js7\js7.encryption\lib

Returns the decrypted value secret of the a previous encryption result resultoperation. The -KeyPath argument specifies the location of the Private Key file. The -JavaLib argument specifies the location of the JS7 encryption libraries.

...

PS > Invoke-JS7Decrypt -Value $result -File /tmp/secret.txt.enc -OutFile /tmp/secret.txt.dec -KeyPath C:\js7\js7.encryption\agent.key -KeyPassword KeyCredential (New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'key', ( 'jobscheduler' | ConvertTo-SecureString -AsPlainText -Force)) -JavaLib C:\js7\js7.encryption\lib

Returns Creates the decrypted file from a previous encryption resultoperation. The -KeyPath argument specifies the location of the Private Key file. The -JavaLib argument specifies the location of the JS7 encryption libraries.