Name

Invoke-JS7Decrypt

SYNOPSIS

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

SYNTAX

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

DESCRIPTION

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

PARAMETERS

Value

-Value <String>
Specifies the 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

-File <String>
Specifies the location of the encrypted file that should be decrypted.

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

OutFile

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

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

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

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

-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

-JavaHome <String>
Specifies the location to which Java is installed. Java is required to 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.

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

JavaLib

-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 decryption outside of JS7 products the JS7 encryption libraries are available for download.

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

JavaOptions

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

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

WhatIf

-WhatIf <SwitchParameter>

Required?false
Position?named
Default value
Accept pipeline input?false
Accept wildcard characters?false

Confirm

-Confirm <SwitchParameter>

Required?false
Position?named
Default value
Accept pipeline input?false
Accept wildcard characters?false

about_JS7

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------

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

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

-------------------------- EXAMPLE 2 --------------------------

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

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

  • No labels