

# UEFI 보안 부팅에 대한 AWS 바이너리 blob 생성
<a name="aws-binary-blob-creation"></a>

다음 단계를 사용하여 AMI 생성 중 UEFI 보안 부팅 변수를 사용자 지정할 수 있습니다. 이 단계에서 사용되는 KEK는 2021년 9월 현재 최신 버전입니다. Microsoft에서 KEK를 업데이트하는 경우 최신 KEK를 사용해야 합니다.

**AWS 바이너리 blob 생성**

1. 빈 PK 서명 목록을 생성합니다.

   ```
   touch empty_key.crt
   cert-to-efi-sig-list empty_key.crt PK.esl
   ```

1. KEK 인증서를 다운로드합니다.

   ```
   https://go.microsoft.com/fwlink/?LinkId=321185
   ```

1. UEFI 서명 목록(`siglist`)에서 KEK 인증서를 래핑합니다.

   ```
   sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_Win_KEK.esl MicCorKEKCA2011_2011-06-24.crt 
   ```

1. Microsoft의 db 인증서를 다운로드합니다.

   ```
   https://www.microsoft.com/pkiops/certs/MicWinProPCA2011_2011-10-19.crt
   https://www.microsoft.com/pkiops/certs/MicCorUEFCA2011_2011-06-27.crt
   ```

1. db 서명 목록을 생성합니다.

   ```
   sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_Win_db.esl MicWinProPCA2011_2011-10-19.crt
   sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_UEFI_db.esl MicCorUEFCA2011_2011-06-27.crt
   cat MS_Win_db.esl MS_UEFI_db.esl > MS_db.esl
   ```

1. 통합 확장 가능 펌웨어 인터페이스 포럼은 더 이상 DBX 파일을 제공하지 않습니다. 이제 Microsoft가 GitHub에서 제공합니다. Microsoft 보안 부팅 업데이트 리포지토리([https://github.com/microsoft/secureboot\$1objects](https://github.com/microsoft/secureboot_objects))에서 최신 DBX 업데이트를 다운로드합니다.

1. 서명된 update-binary의 압축을 풉니다.

   아래 스크립트 콘텐츠로 `SplitDbxContent.ps1`을 생성합니다. 또는 `Install-Script -Name SplitDbxContent`를 사용하여 [ PowerShell Gallery](https://www.powershellgallery.com/packages/SplitDbxContent/1.0)에서 스크립트를 설치할 수 있습니다.

   ```
   <#PSScriptInfo
    
   .VERSION 1.0
    
   .GUID ec45a3fc-5e87-4d90-b55e-bdea083f732d
    
   .AUTHOR Microsoft Secure Boot Team
    
   .COMPANYNAME Microsoft
    
   .COPYRIGHT Microsoft
    
   .TAGS Windows Security
    
   .LICENSEURI
    
   .PROJECTURI
    
   .ICONURI
    
   .EXTERNALMODULEDEPENDENCIES
    
   .REQUIREDSCRIPTS
    
   .EXTERNALSCRIPTDEPENDENCIES
    
   .RELEASENOTES
   Version 1.0: Original published version.
    
   #>
   
   <#
   .DESCRIPTION
    Splits a DBX update package into the new DBX variable contents and the signature authorizing the change.
    To apply an update using the output files of this script, try:
    Set-SecureBootUefi -Name dbx -ContentFilePath .\content.bin -SignedFilePath .\signature.p7 -Time 2010-03-06T19:17:21Z -AppendWrite'
   .EXAMPLE
   .\SplitDbxAuthInfo.ps1 DbxUpdate_x64.bin
   #>
   
   
   # Get file from script input
   $file  = Get-Content -Encoding Byte $args[0]
   
   # Identify file signature
   $chop = $file[40..($file.Length - 1)]
   if (($chop[0] -ne 0x30) -or ($chop[1] -ne 0x82 )) {
       Write-Error "Cannot find signature"
       exit 1
   }
   
   # Signature is known to be ASN size plus header of 4 bytes
   $sig_length = ($chop[2] * 256) + $chop[3] + 4
   $sig = $chop[0..($sig_length - 1)]
   
   if ($sig_length -gt ($file.Length + 40)) {
       Write-Error "Signature longer than file size!"
       exit 1
   }
   
   # Content is everything else
   $content = $file[0..39] + $chop[$sig_length..($chop.Length - 1)]
   
   # Write signature and content to files
   Set-Content -Encoding Byte signature.p7 $sig
   Set-Content -Encoding Byte content.bin $content
   ```

   스크립트를 사용하여 서명된 DBX 파일의 압축을 풉니다.

   ```
   PS C:\Windows\system32> SplitDbxContent.ps1 .\dbx.bin
   ```

   이렇게 하면 `signature.p7` 및 `content.bin`이라는 두 파일이 생성됩니다. 다음 단계에서 `content.bin`을 사용합니다.

1. `uefivars.py` 스크립트를 사용하여 UEFI 변수 스토어를 빌드합니다.

   ```
   ./uefivars.py -i none -o aws -O uefiblob-microsoft-keys-empty-pk.bin -P ~/PK.esl -K ~/MS_Win_KEK.esl --db ~/MS_db.esl  --dbx ~/content.bin 
   ```

1. 바이너리 blob과 UEFI 변수 스토어를 확인합니다.

   ```
   ./uefivars.py -i aws -I uefiblob-microsoft-keys-empty-pk.bin -o json | less
   ```

1. Blob을 동일한 도구에 다시 전달하여 업데이트할 수 있습니다.

   ```
   ./uefivars.py -i aws -I uefiblob-microsoft-keys-empty-pk.bin -o aws -O uefiblob-microsoft-keys-empty-pk.bin -P ~/PK.esl -K ~/MS_Win_KEK.esl --db ~/MS_db.esl  --dbx ~/content.bin
   ```

   예상 결과

   ```
   Replacing PK
   Replacing KEK
   Replacing db
   Replacing dbx
   ```