HP.Firmware.SecurePlatform.psm1
# Copyright (C)2018 HP Inc # All Rights Reserved. # # NOTICE: All information contained herein is, and remains the property of HP Inc. # # The intellectual and technical concepts contained herein are proprietary to HP Inc # and may be covered by U.S. and Foreign Patents, patents in process, and are protected by # trade secret or copyright law. Dissemination of this information or reproduction of this material # is strictly forbidden unless prior written permission is obtained from HP Inc. Set-StrictMode -Version 3.0 $ErrorActionPreference = "Stop" #requires -Modules "HP.Private" <# .SYNOPSIS Get the HP Secure Platform state .DESCRIPTION This function returns the state of the HP Secure Platform. .NOTES - Supported on Windows 10. - Requires HP BIOS with secure platform support. - This command requires elevated privileges. #> function Get-HPSecurePlatformState { [CmdletBinding(HelpUri = "https://developers.hp.com/hp-client-management/doc/New%E2%80%90HPSecurePlatformState")] param() $mi_result = 0 $data = New-Object -TypeName provisioning_data_t $c = '[DfmNativeSecurePlatform]::get_secureplatform_provisioning' + (Test-OSBitness) + '([ref]$data,[ref]$mi_result);' $result = Invoke-Expression -Command $c Test-HPPrivateCustomResult -result $result -mi_result $mi_result -Category 0x04 $kek_mod = $data.kek_mod [array]::Reverse($kek_mod) $sk_mod = $data.sk_mod [array]::Reverse($sk_mod) $obj = [ordered]@{ State = $data.State Version = "$($data.subsystem_version[0]).$($data.subsystem_version[1])" Nonce = $($data.arp_counter) FeaturesInUse = $data.features_in_use EndorsementKeyMod = $kek_mod SigningKeyMod = $sk_mod } return New-Object -TypeName PSCustomObject -Property $obj } <# .SYNOPSIS Create an HP Secure Platform payload to provision a _Key Endorsement_ key. .DESCRIPTION The purpose of the endorsement key is to protect the signing key against unauthorized changes. Only holders of the key endorsement private key may change the signing key. On return, the function writes the created payload to the pipeline, or to the file specified in the OutputFile parameter. This payload can then be passed to the [Set-HPSecurePlatformPayload](Set-HPSecurePlatformPayload) function. <div style="background-color: #ee8; padding:10px;"> <h4>Security note</h4> Payloads should only be created on secure servers. Once created, the payload may be transferred to a client and applied via the <b>Set-HPSecurePlatformPayload</b> . Creating the payload and passing it to the <b>Set-HPSecurePlatformPayload</b> function via the pipeline is not a recommended production pattern. </div> .PARAMETER EndorsementKeyFile The _Key Endorsement_ key certificate, as a PFX (PKCS #12) file. .PARAMETER EndorsementKeyFilePassword The password for the _Endorsement Key_ PFX file. If no password was used when the PFX was created (which is not recommended), this parameter may be omitted. .PARAMETER EndorsementKeyCertificate This parameter is currently reserved for internal use only. .PARAMETER EndorsementKeyCertificatePassword This parameter is currently reserved for internal use only. .PARAMETER BIOSPassword The active BIOS Setup password, if any. Note that the password will be in the clear in the generated payload. .PARAMETER OutputFile Write the resulting output to the specified file, instead of writing it to the pipeline. .NOTES The Key Endorsement private key must never leave a secure server. The payload must be created on a secure server, then may be transferred to a client. - Supported on Windows 10. - Requires HP BIOS with secure platform support. .EXAMPLE $payload = New-HPSecurePlatformEndorsementKeyProvisioningPayload -EndorsementKeyFile "$path\endorsement_key.pfx" ... $payload | Set-HPSecurePlatformPayload #> function New-HPSecurePlatformEndorsementKeyProvisioningPayload { [CmdletBinding(DefaultParameterSetName = "EK_FromFile", HelpUri = "https://developers.hp.com/hp-client-management/doc/New%E2%80%90HPSecurePlatformEndorsementKeyProvisioningPayload")] param( [Parameter(ParameterSetName = "EK_FromFile", Mandatory = $true, Position = 0)] [System.IO.FileInfo]$EndorsementKeyFile, [Parameter(ParameterSetName = "EK_FromFile", Mandatory = $false, Position = 1)] [string]$EndorsementKeyPassword, [Parameter(ParameterSetName = "EK_FromBytes", Mandatory = $true, Position = 0)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$EndorsementKeyCertificate, [Parameter(ParameterSetName = "EK_FromFile", Mandatory = $false, Position = 2)] [Parameter(ParameterSetName = "EK_FromBytes", Mandatory = $false, Position = 2)] [string]$BIOSPassword, [Parameter(ParameterSetName = "EK_FromFile", Mandatory = $false, Position = 3)] [Parameter(ParameterSetName = "EK_FromBytes", Mandatory = $false, Position = 3)] [System.IO.FileInfo]$OutputFile ) $crt = (Get-HPPrivateX509CertCoalesce -File $EndorsementKeyFile -cert $EndorsementKeyCertificate -password $EndorsementKeyPassword -Verbose:$VerbosePreference).Certificate Write-Verbose "Creating EK provisioning payload" if ($BIOSPassword) { $passwordLength = $BIOSPassword.Length } else { $passwordLength = 0 } $opaque = New-Object opaque4096_t $opaqueLength = 4096 $mi_result = 0 $cmd = '[DfmNativeSecurePlatform]::get_ek_provisioning_data' + (Test-OSBitness) + '($crt,$($crt.Count),$BIOSPassword, $passwordLength, [ref]$opaque, [ref]$opaqueLength, [ref]$mi_result);' $result = Invoke-Expression -Command $cmd Test-HPPrivateCustomResult -result $result -mi_result $mi_result -Category 0x04 $output = New-Object -TypeName PortableFileFormat $output.data = $opaque.raw[0..($opaqueLength - 1)] $output.purpose = "hp:provision:endorsementkey" $output.timestamp = Get-Date if ($OutputFile) { Write-Verbose 'Will output to file $OutputFile' $f = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputFile) $output | ConvertTo-Json -Compress | Out-File $f -Encoding utf8 } else { $output | ConvertTo-Json -Compress } } <# .SYNOPSIS Create an HP Secure Platform payload to provision a _Signing Key_ key. .DESCRIPTION The purpose of the signing key is to sign commands for the secure platform. The Signing key is protected by the endorsement key, therefore the endorsement key private key must be available when provisioning or changing the signing key. On return, the function writes the created payload to the pipeline, or to the file specified in the OutputFile parameter. This payload can then be passed to the [Set-HPSecurePlatformPayload](Set-HPSecurePlatformPayload) function. <div style="background-color: #ee8; padding:10px;"> <h4>Security note</h4> Payloads should only be created on secure servers. Once created, the payload may be transferred to a client and applied via the <b>Set-HPSecurePlatformPayload</b> . Creating the payload and passing it to the <b>Set-HPSecurePlatformPayload</b> function via the pipeline is not a recommended production pattern. </div> .PARAMETER EndorsementKeyFile The _Key Endorsement_ key certificate, as a PFX (PKCS #12) file. The endorsement key protects the signing key. .PARAMETER EndorsementKeyPassword The password for the _Endorsement Key_ PFX file. If no password was used when the PFX was created (which is not recommended), this parameter may be omitted. .PARAMETER EndorsementKeyCertificate The endorsement key certificate, as an X509Certificate object. .PARAMETER SigningKeyFile The signing key certificate, as a PFX (PKCS #12) file. The endorsement key protects the signing key. .PARAMETER SigningKeyCertificate The signing key certificate, as an X509Certificate object. .PARAMETER SigningKeyCertificate This parameter is currently reserved for internal use only. .PARAMETER SigningKeyPassword The signing key certificate, as an X509Certificate object. .PARAMETER Nonce The operation nonce. In order to prevent replay attacks, the secure platform subsystem will only accept commands with a nonce greater or equal to the last nonce sent. If not specified, the nonce is inferred from the current local time. This works okay in most cases, however this approach has a resolution of seconds, so when doing high volume or parallel operations, it is possible to infer the same counter for two or more commands. In those cases, the caller should use its own nonce derivation and provide it through this parameter. .PARAMETER OutputFile Write the resulting output to the specified file, instead of writing it to the pipeline. .NOTES - Supported on Windows 10. - Requires HP BIOS with secure platform support. .EXAMPLE $payload = New-HPSecurePlatformSigningKeyProvisioningPayload -EndorsementKeyFile "$path\endorsement_key.pfx" ` -SigningKeyFile "$path\signing_key.pfx" ... $payload | Set-HPSecurePlatformPayload #> function New-HPSecurePlatformSigningKeyProvisioningPayload { [CmdletBinding(DefaultParameterSetName = "EF_SF", HelpUri = "https://developers.hp.com/hp-client-management/doc/New%E2%80%90HPSecurePlatformSigningKeyProvisioningPayload")] param( [Parameter(ParameterSetName = "EF_SF", Mandatory = $true, Position = 0)] [Parameter(ParameterSetName = "EF_SB", Mandatory = $true, Position = 0)] [System.IO.FileInfo]$EndorsementKeyFile, [Parameter(ParameterSetName = "EF_SF", Mandatory = $false, Position = 1)] [Parameter(ParameterSetName = "EF_SB", Mandatory = $false, Position = 1)] [string]$EndorsementKeyPassword, [Parameter(ParameterSetName = "EF_SF", Mandatory = $false, Position = 2)] [Parameter(ParameterSetName = "EB_SF", Mandatory = $false, Position = 2)] [System.IO.FileInfo]$SigningKeyFile, [Parameter(ParameterSetName = "EF_SF", Mandatory = $false, Position = 3)] [Parameter(ParameterSetName = "EB_SF", Mandatory = $false, Position = 3)] [string]$SigningKeyPassword, [Parameter(ParameterSetName = "EB_SF", Mandatory = $true, Position = 0)] [Parameter(ParameterSetName = "EB_SB", Mandatory = $true, Position = 0)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$EndorsementKeyCertificate, [Parameter(ValueFromPipeline=$true, ParameterSetName = "EB_SB", Mandatory = $false, Position = 2)] [Parameter(ValueFromPipeline=$true, ParameterSetName = "EF_SB", Mandatory = $false, Position = 2)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$SigningKeyCertificate, [Parameter(ParameterSetName = "EF_SF", Mandatory = $false, Position = 4)] [Parameter(ParameterSetName = "EB_SF", Mandatory = $false, Position = 4)] [Parameter(ParameterSetName = "EF_SB", Mandatory = $false, Position = 4)] [Parameter(ParameterSetName = "EB_SB", Mandatory = $false, Position = 4)] [uint32]$Nonce = [math]::Floor([decimal](Get-Date (Get-Date).ToUniversalTime() -UFormat "%s")), [Parameter(ParameterSetName = "EF_SF", Mandatory = $false, Position = 5)] [Parameter(ParameterSetName = "EB_SF", Mandatory = $false, Position = 5)] [Parameter(ParameterSetName = "EF_SB", Mandatory = $false, Position = 5)] [Parameter(ParameterSetName = "EB_SB", Mandatory = $false, Position = 5)] [System.IO.FileInfo]$OutputFile ) $ek = Get-HPPrivateX509CertCoalesce -File $EndorsementKeyFile -password $EndorsementKeyPassword -cert $EndorsementKeyCertificate -Verbose:$VerbosePreference $sk = $null if ($SigningKeyFile -or $SigningKeyCertificate) { $sk = Get-HPPrivateX509CertCoalesce -File $SigningKeyFile -password $SigningKeyPassword -cert $SigningKeyCertificate -Verbose:$VerbosePreference } Write-Verbose "Creating SK provisioning payload" $payload = New-Object sk_provisioning_t $sub = New-Object sk_provisioning_payload_t $sub.Counter = $nonce if ($sk) { $sub.mod = $Sk.Modulus } else { Write-Verbose "Assuming deprovisioning due to missing signing key update" $sub.mod = New-Object byte[] 256 } $payload.data = $sub Write-Verbose "Using counter value of $($sub.Counter)" $out = Convert-HPPrivateObjectToBytes -obj $sub -Verbose:$VerbosePreference $payload.sig = Invoke-HPPrivateSignData -data $out[0] -Certificate $ek.Full -Password $SigningKeyPassword -Verbose:$VerbosePreference Write-Verbose "Serializing payload" $out = Convert-HPPrivateObjectToBytes -obj $payload -Verbose:$VerbosePreference $output = New-Object -TypeName PortableFileFormat $output.data = ($out[0])[0..($out[1] - 1)]; $output.purpose = "hp:provision:signingkey" $output.timestamp = Get-Date if ($OutputFile) { Write-Verbose 'Will output to file $OutputFile' $f = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputFile) $output | ConvertTo-Json -Compress | Out-File -FilePath $f -Encoding utf8 } else { $output | ConvertTo-Json -Compress } } <# .SYNOPSIS Create a deprovisioning payload .DESCRIPTION This function creates a payload to deprovision the HP Secure Platform. The caller must have access to the Endorsement Key private key in order to create this payload. On return, the function writes the created payload to the pipeline, or to the file specified in the OutputFile parameter. This payload can then be passed to the [Set-HPSecurePlatformPayload](Set-HPSecurePlatformPayload) function. <div style="background-color: #ee8; padding:10px;"> <h4>Security note</h4> Payloads should only be created on secure servers. Once created, the payload may be transferred to a client and applied via the <b>Set-HPSecurePlatformPayload</b> . Creating the payload and passing it to the <b>Set-HPSecurePlatformPayload</b> function via the pipeline is not a recommended production pattern. </div> .PARAMETER EndorsementKeyFile The _Key Endorsement_ key certificate, as a PFX (PKCS #12) file. .PARAMETER EndorsementKeyPassword The password for the endorsement key certificate file. If no password was used when the PFX was created (which is not recommended), this parameter may be omitted. .PARAMETER EndorsementKeyCertificate The endorsement key certificate, as an X509Certificate object. .PARAMETER Nonce The operation nonce. In order to prevent replay attacks, the secure platform subsystem will only accept commands with a nonce greater or equal to the last nonce sent. If not specified, the nonce is inferred from the current local time. This works okay in most cases, however this approach has a resolution of seconds, so when doing high volume or parallel operations, it is possible to infer the same counter for two or more commands. In those cases, the caller should use its own nonce derivation and provide it through this parameter. .PARAMETER OutputFile Write the resulting output to the specified file, instead of writing it to the pipeline. .NOTES - Supported on Windows 10. - Requires HP BIOS with secure platform support. #> function New-HPSecurePlatformDeprovisioningPayload { [CmdletBinding(DefaultParameterSetName = "EF", HelpUri = "https://developers.hp.com/hp-client-management/doc/New%E2%80%90HPSecurePlatformDeprovisioningPayload")] param( [Parameter(ParameterSetName = "EF", Mandatory = $true, Position = 0)] [string]$EndorsementKeyFile, [Parameter(ParameterSetName = "EF", Mandatory = $false, Position = 1)] [string]$EndorsementKeyPassword, [Parameter(ParameterSetName = "EF", Mandatory = $false, Position = 2)] [Parameter(ParameterSetName = "EB", Mandatory = $false, Position = 2)] [uint32]$nonce = [math]::Floor([decimal](Get-Date (Get-Date).ToUniversalTime() -UFormat "%s")), [Parameter(ParameterSetName = "EB", Mandatory = $true, Position = 0)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$EndorsementKeyCertificate, [Parameter(ParameterSetName = "EB", Mandatory = $false, Position = 4)] [Parameter(ParameterSetName = "EF", Mandatory = $false, Position = 4)] [System.IO.FileInfo]$OutputFile ) New-HPSecurePlatformSigningKeyProvisioningPayload @PSBoundParameters } <# .SYNOPSIS Apply a payload to the HP Secure Platform .DESCRIPTION This function applies a properly encoded payload created by one of the New-HPSecurePlatform*, New-HPSureRun*, or New-HPSureRecover* functions to the BIOS. For all purposes, payload objects should be considered to be opaque. Payloads created by means other than the functions mentioned above are not supported. <div style="background-color: #ee8; padding:10px;"> <h4>Security note</h4> Payloads should only be created on secure servers. Once created, the payload may be transferred to a client and applied via the <b>Set-HPSecurePlatformPayload</b> . Creating the payload and passing it to the <b>Set-HPSecurePlatformPayload</b> function via the pipeline is not a recommended production pattern. </div> .PARAMETER Payload The payload to apply. This parameter can also be specified via the pipeline. .PARAMETER PayloadFile The payload file to apply. This file must contain a properly encoded payload. .NOTES - Supported on Windows 10. - Requires HP BIOS with secure platform support. - This command requires elevated privileges. #> function Set-HPSecurePlatformPayload { [CmdletBinding(DefaultParameterSetName = "FB", HelpUri = "https://developers.hp.com/hp-client-management/doc/New%E2%80%90HPSecurePlatformPayload")] param( [Parameter(ParameterSetName = "FB", ValueFromPipeline=$true, Position = 0, Mandatory = $True)] [string]$Payload, [Parameter(ParameterSetName = "FF", ValueFromPipeline=$true, Position = 0, Mandatory = $True)] [System.IO.FileInfo]$PayloadFile ) if ($PSCmdlet.ParameterSetName -eq "FB") { Write-Verbose "Setting payload string" [PortableFileFormat]$type = ConvertFrom-Json -InputObject $Payload } else { Write-Verbose "Setting from file $PayloadFile" [PortableFileFormat]$type = Get-Content -Path $PayloadFile -Encoding UTF8 | ConvertFrom-Json } $mi_result = 0 $pbytes = $type.data Write-Verbose "Setting payload from document with type $($type.purpose)" switch ($type.purpose) { "hp:provision:endorsementkey" { $cmd = '[DfmNativeSecurePlatform]::set_ek_provisioning' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:provision:signingkey" { $cmd = '[DfmNativeSecurePlatform]::set_sk_provisioning' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:provision:os_image" { $cmd = '[DfmNativeSureRecover]::set_surerecover_osr_provisioning' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:provision:recovery_image" { $cmd = '[DfmNativeSureRecover]::set_surerecover_re_provisioning' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:deprovision" { $cmd = '[DfmNativeSureRecover]::set_surerecover_deprovision_opaque' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:scheduler" { $cmd = '[DfmNativeSureRecover]::set_surerecover_schedule' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:configure" { $cmd = '[DfmNativeSureRecover]::set_surerecover_configuration' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:trigger" { $cmd = '[DfmNativeSureRecover]::set_surerecover_trigger' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' } "hp:surerecover:service_event" { $cmd = '[DfmNativeSureRecover]::raise_surerecover_service_event_opaque' + (Test-OSBitness) + '($null,0, [ref]$mi_result);' } "hp:surerrun:manifest" { $mbytes = $type.Meta1 $cmd = '[DfmNativeSureRun]::set_surererun_manifest' + (Test-OSBitness) + '($pbytes,$pbytes.length, $mbytes, $mbytes.length, [ref]$mi_result);' } default { throw [System.IO.InvalidDataException]"Document type $($type.purpose) not recognized" } } #$cmd = '[DfmNativeSecurePlatform]::set_sk_provisioning' + (Test-OSBitness) + '($pbytes,$pbytes.length, [ref]$mi_result);' $result = Invoke-Expression -Command $cmd Test-HPPrivateCustomResult -result $result -mi_result $mi_result -Category 0x04 } <# .SYNOPSIS #TODO .DESCRIPTION #TODO .PARAMETER Payload #TODO .PARAMETER PayloadFile #TODO .NOTES #TODO #> function ConvertTo-HPSecurePlatformPayload { [CmdletBinding(DefaultParameterSetName = "SigningKeyFile", HelpUri = "https://developers.hp.com/hp-client-management/doc/ConvertTo%E2%80%90HPSecurePlatformPayload")] param( [Parameter(ValueFromPipeline=$true, ParameterSetName = "SigningKeyFile", Mandatory = $true, Position = 0)] [Parameter(ValueFromPipeline=$true, ParameterSetName = "SigningKeyCert", Mandatory = $true, Position = 0)] [object[]]$InputObject, [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $true, Position = 1)] [System.IO.FileInfo]$SigningKeyFile, [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $false, Position = 2)] [string]$SigningKeyPassword, [Parameter(ValueFromPipeline=$true, ParameterSetName = "SigningKeyCert", Mandatory = $true, Position = 3)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$SigningKeyCertificate, [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $false, Position = 4)] [Parameter(ParameterSetName = "SigningKeyCert", Mandatory = $false, Position = 4)] [uint32]$Nonce = [math]::Floor([decimal](Get-Date (Get-Date).ToUniversalTime() -UFormat "%s")), [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $false, Position = 5)] [Parameter(ParameterSetName = "SigningKeyCert", Mandatory = $false, Position = 5)] [ValidatePattern('^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$')] [string]$TargetUUID = 'ffffffff-ffff-ffff-ffff-ffffffffffff', [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $false, Position = 5)] [Parameter(ParameterSetName = "SigningKeyCert", Mandatory = $false, Position = 5)] [switch]$SingleUse, [Parameter(ParameterSetName = "SigningKeyFile", Mandatory = $false, Position = 6)] [Parameter(ParameterSetName = "SigningKeyCert", Mandatory = $false, Position = 6)] [System.IO.FileInfo]$OutputFile ) $output = New-Object -TypeName PortableFileFormat $settings= New-Object -TypeName SureAdminSettings $output.timestamp = Get-Date $output.Meta1 = [BitConverter]::GetBytes( $InputObject.Count) $output.purpose = "hp:sureadmin:bios_settings" foreach ($obj in $InputObject) { switch($obj.type) { 'hp:sureadmin:bios_setting' { $setting = New-Object -TypeName SureAdminSetting $setting.Name = $obj.Name $setting.Value = $obj.Value $setting.Auth = (makeSignature -certFile $SigningKeyFile -certFilePassword $SigningKeyPassword -cert $SigningKeyCertificate -target $TargetUUID -nonce $Nonce -singleUse $SingleUse.IsPresent -name $obj.Name -value $obj.value) $settings.settings.Add($setting) } default { throw [InvalidOperationException]"Unknown object identifier $($obj.type)" } } } $output.Data = [System.Text.Encoding]::UTF8.GetBytes( ($settings | ConvertTo-Json) ) if ($OutputFile) { Write-Verbose 'Will output to file $OutputFile' $f = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputFile) $output | ConvertTo-Json -Compress | Out-File -FilePath $f -Encoding utf8 } else { $output | ConvertTo-Json -Compress } } function makeSignature { [CmdletBinding()] param( [string]$name, [string]$value, [int]$nonce, [bool]$singleUse, [string]$target, [System.Security.Cryptography.X509Certificates.X509Certificate2]$cert, [string]$certFile, [string]$certFilePassword ) $data = new-object -TypeName SureAdminSignatureBlockHeader $data.Version = 1 $data.NameLength = [System.Text.Encoding]::Unicode.GetByteCount($name) $data.ValueLength = [System.Text.Encoding]::Unicode.GetByteCount($value) $data.OneTimeUse = [byte]$singleUse $data.Reserved = 0 $data.Nonce = $nonce $data.Target = [byte[]] (($target.replace('-','')) -replace '..', '0x$&,' -split ',' -ne '') $head = (Convert-HPPrivateObjectToBytes -obj $data -Verbose:$VerbosePreference)[0] $payload = new-object byte[] ($head.Count + $data.NameLength + $data.ValueLength) $namebytes = [System.Text.Encoding]::Unicode.GetBytes($name) $valuebytes = [System.Text.Encoding]::Unicode.GetBytes($value) [System.Array]::Copy($head, 0, $payload, 0, $head.Count) [System.Array]::Copy($namebytes, 0, $payload, $head.Count, $namebytes.Count) [System.Array]::Copy($valuebytes, 0, $payload, $head.Count + $namebytes.Count, $valuebytes.Count) $params = @{ data = $payload } if ($certFile) { $params.add("FileName", $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($certFile)); $params.add("Password", $certFilePassword); } else { $params.add("Certificate", $cert) } [byte[]]$sign = Invoke-HPPrivateSignData @params $result = new-object byte[] ($sign.Length + $payload.Length) [System.Array]::Copy($payload, 0, $result, 0, $payload.Length) [System.Array]::Copy($sign, 0, $result, $payload.Length, $sign.Length) $result } # SIG # Begin signature block # MIIcNwYJKoZIhvcNAQcCoIIcKDCCHCQCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBesLEAIS5VH1qj # pdMTBySp3541wlH5X6xREsTolAlzoqCCCo0wggU2MIIEHqADAgECAhAM1s71mz4i # 3j/UnuaI4vzeMA0GCSqGSIb3DQEBCwUAMHYxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xNTAzBgNV # BAMTLERpZ2lDZXJ0IFNIQTIgSGlnaCBBc3N1cmFuY2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