IBM Cloud Docs
Oracle Transparent Database Encryption에 대해 Hyper Protect Crypto Services PKCS #11 사용

Oracle Transparent Database Encryption에 대해 Hyper Protect Crypto Services PKCS #11 사용

TDE(Transparent Data Encryption)는 데이터베이스에서 민감한 데이터를 암호화하는 성공적으로 구축된 기술입니다. TDE는 클라우드 및 온프레미스 양쪽에서 자주 사용되는 다양한 데이터베이스 시스템(예: Oracle® 데이터베이스)에서 지원됩니다. TDE를 사용하는 경우 데이터베이스 시스템에서 데이터베이스 스토리지 매체(예: 테이블스페이스 및 파일) 및 백업 매체의 데이터를 암호화합니다. 데이터베이스 시스템은 권한 있는 사용자 및 애플리케이션이 사용할 때 데이터를 자동으로 투명하게 암호화하고 복호화합니다. 데이터베이스 사용자는 기본 암호화를 알아야 할 필요가 없고, 데이터베이스 애플리케이션은 TDE에 맞게 특별히 조정될 필요가 없습니다.

일반적으로 TDE는 TDE 마스터 암호화 키 및 TDE 데이터 암호화 키로 구성된 2계층 키 계층 구조를 사용합니다. TDE 데이터 암호화 키는 데이터를 암호화하고 복호화하는 데 사용되고, TDE 마스터 암호화 키는 TDE 데이터 암호화 키를 암호화하고 복호화하는 데 사용됩니다.

따라서 TDE를 계획할 때 중요한 한 가지 질문은 TDE 마스터 암호화 키를 어디에 보관하고 어떻게 보호할 것인가입니다.

목표

이 튜토리얼에서는 IBM Cloud® Hyper Protect Crypto Services에 TDE 마스터 암호화 키를 보관하여 완전하고 독점적으로 마스터 키를 계속 제어할 수 있습니다. 이를 위해 Hyper Protect Crypto Services의 PKCS #11 통합 기능을 사용해야 합니다.

이 튜토리얼을 통해 다음 그림에 표시된 설정을 구현합니다.

표준 PKCS #11 API를 사용한 투명한 데이터베이스 암호화
그림 1. 표준 PKCS #11 API를 사용한 Transparent Database 암호화

이 설정에서 Oracle Database는 Hyper Protect Crypto Services PKCS #11 라이브러리에서 TDE 마스터 암호화 키를 관리하기 위한 오퍼레이션을 호출합니다. Hyper Protect Crypto Services PKCS #11 라이브러리는 TDE 마스터 암호화 키를 저장하고 관리하기 위해 최상의 기술을 제공하는 Hyper Protect Crypto Services 인스턴스와 통합합니다.

시작하기 전에

이 튜토리얼을 완료하려면 다음 전제조건을 충족해야 합니다.

태스크 플로우

이 솔루션을 완료하려면 다음 단계를 수행하십시오.

  1. Hyper Protect Crypto Services 인스턴스를 초기화하십시오.
  2. Oracle Database 환경에서 Hyper Protect Crypto Services PKCS #11 라이브러리를 설정하십시오.
  3. Oracle Database TDE를 설정하고 데이터를 암호화하십시오.

Hyper Protect Crypto Services 인스턴스 초기화 프로세스를 시작하십시오.

Hyper Protect Crypto Services 인스턴스 초기화

  1. 이 튜토리얼의 경우 먼저 Hyper Protect Crypto Services 인스턴스를 초기화해야 합니다.

    Hyper Protect Crypto Services 인스턴스의 ID 및 EP11 엔드포인트 주소를 적어 놓으십시오. 후속 단계를 위해 이 정보가 필요합니다.

  2. Hyper Protect Crypto Services 인스턴스에 액세스하기 위해 API 키를 생성하십시오. IBM Cloud 계정에 대한 API 키를 작성하려면 다음 명령을 실행하십시오.

    ibmcloud iam api-key-create apikeyhpcs -d "API key for Hyper Protect Crypto Services PKCS11"
    
  3. 후속 단계를 위해 API 키의 값을 저장하십시오.

Oracle Database 환경에서 Hyper Protect Crypto Services PKCS #11 라이브러리 설정

1. Oracle Database 설정

Oracle Advanced Security와 함께 Oracle Database Enterprise Edition이 설치되어 있어야 합니다. 이 튜토리얼에서는 단일 인스턴스 Oracle Database 19.3 Enterprise Edition Docker 컨테이너를 사용합니다. Oracle Database 컨테이너에 대한 자세한 정보 및 각 컨테이너 빌드에 대한 지시사항은 Docker 의 Oracle Database의 내용을 참조하십시오.

  1. Oracle Database 컨테이너를 시작하십시오.

    docker run --name oradb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=password oracle/database:19.3.0-ee
    

    인스턴스 및 데이터베이스 작성이 완료될 때까지 기다리십시오.

  2. 호스트 시스템의 명령행에서 다음 명령을 실행하십시오.

    docker exec -it --user root --workdir / oradb bash
    

    이 쉘은 후속 단계에서 root로 명령을 실행하기 위해 사용될 수 있습니다.

2. Hyper Protect Crypto Services PKCS #11 라이브러리 구성

이제 Hyper Protect Crypto Services PKCS #11 기능에 대한 구성 파일을 작성하십시오. 구성 파일의 이름은 grep11client.yaml입니다.

다음 파일 템플리트를 조정하고 파일의 이름을 grep11client.yaml로 지정하십시오.

  • <instance_ID>을(를) Hyper Protect Crypto Services 인스턴스의 ID로 대체하십시오.
  • <EP11_endpoint_URL><EP11_endpoint_port_number>을(를) Hyper Protect Crypto Services 인스턴스의 EP11 엔드포인트 주소에 대한 각 매개변수로 대체하십시오.
  • <your_api_key>을(를) 작성된 API 키의 값으로 대체하십시오.
iamcredentialtemplate: &defaultiamcredential
          enabled: true
          endpoint: "https://iam.cloud.ibm.com"
          # Keep the 'apikey' empty. It will be overridden by the Anonymous user API key configured later.
          apikey:
          # The Universally Unique IDentifier (UUID) of your Hyper Protect Crypto Services instance.
          instance: "<instance_ID>"

tokens:
  0:
    grep11connection:
      # The EP11 endpoint address starting from 'ep11'.
      # For example: "<instance_ID>.ep11.us-south.hs-crypto.appdomain.cloud"
      address: "<EP11_endpoint_URL>"
      # The EP11 endpoint port number
      port: "<EP11_endpoint_port_number>"
      tls:
        # Grep11 requires TLS connection.
        enabled: true
        # Grep11 requires server only authentication, so 'mutual' needs to be set as 'false'.
        mutual: false
        # 'cacert' is a full-path certificate file.
        # In Linux with the 'ca-ca-certificates' package installed, this is normally not needed.
        cacert:
        # Grep11 requires the server-only authentication, so 'certfile' and 'keyfile' need to be empty.
        certfile:
        keyfile:
    storage:
      filestore:
        enabled: false
        storagepath:
        # 'remotestore' needs to be enabled if you want to generate keys with the attribute CKA_TOKEN.
      remotestore:
        enabled: true
    users:
      0: # The index of the Security Officer (SO) user MUST be 0.
        # The name for the Security Officer (SO) user. For example: "Administrator".
        # NEVER put the API key under the SO user for security reasons.
        name: "Administrator"
        iamauth:
          <<: *defaultiamcredential
      1: # The index of the normal user MUST be 1.
        # The name for the normal user. For example: "Normal user".
        # NEVER put the API key under the normal user for security reasons.
        name: "Normal user"
         # The Space ID is a 128-bit UUID and can be chosen freely.
         # The UUID can be generated by third-party tools, such as 'https://www.uuidgenerator.net/'.
         # For example: "f00db2f1-4421-4032-a505-465bedfa845b".
         # 'tokenspaceID' under the normal user is to identify the private keystore.
        tokenspaceID: "f00db2f1-4421-4032-a505-465bedfa845b"
        iamauth:
          <<: *defaultiamcredential
      2: # The index of the anonymous user MUST be 2.
        # The name for the anonymous user. For example: "Anonymous".
        name: "Anonymous"
        # The Space ID is a 128-bit UUID and can be chosen freely.
        # The UUID can be generated by third-party tools, such as 'https://www.uuidgenerator.net/'.
        # For example: "ca22be26-b798-4fdf-8c83-3e3a492dc215".
        # 'tokenspaceID' under the anonymous user is to identify the public keystore.
        tokenspaceID: "ca22be26-b798-4fdf-8c83-3e3a492dc215"
        iamauth:
          <<: *defaultiamcredential
          # This API key for the Anonymous user must be provided.
          # It will overide the 'apikey' in the previous defaultcredentials.iamauth.apikey field
          apikey: "<your_api_key>"
logging:
  # Set the logging level.
  # The supported levels, in an increasing order of verboseness, are:
  # 'panic', 'fatal', 'error', 'warning'/'warn', 'info', 'debug', 'trace'.
  # The Default value is 'debug'.
  loglevel: debug
  # The full path of your logging file.
  # For example: /tmp/grep11client.log
  logpath: /tmp/grep11client.log

3. Hyper Protect Crypto Services PKCS #11 라이브러리 설치

  1. 최신 PKCS #11 라이브러리를 다운로드하십시오.

  2. 작성된 구성 파일 grep11client.yaml 및 PKCS #11 라이브러리 pkcs11-grep11-<platform>.so.<version>을(를) Oracle Database 컨테이너의 홈 폴더에 복사하십시오.

  3. root로 다음 명령을 실행하여 Oracle Database 설정에 Hyper Protect Crypto Services PKCS #11 라이브러리를 설치하십시오.

    mkdir /etc/ep11client
    chmod a+rx /etc/ep11client/
    cp grep11client.yaml /etc/ep11client/grep11client.yaml
    chmod a+r /etc/ep11client/grep11client.yaml
    
    mkdir -p /opt/oracle/extapi/64/hsm/ibm
    cp pkcs11-grep11.so.1.1.3 /opt/oracle/extapi/64/hsm/ibm/pkcs11-grep11.so
    chown -R oracle:oinstall /opt/oracle/extapi
    
    touch /tmp/grep11client.log
    chmod a+rw /tmp/grep11client.log
    chown oracle:oinstall /tmp/grep11client.log
    

/opt/oracle/extapi/64/hsm 디렉토리 및 서브디렉토리에는 하나의 2진 파일만 포함되어야 합니다. 해당 디렉토리 및 서브디렉토리에 존재하는 다른 파일을 제거하십시오.

4. 라이브러리 설정 확인

  1. 다음 명령을 사용하여 명령행 유틸리티 OpenSC(pkcs11 도구)를 설치하십시오.

    sudo yum install opensc
    
  2. root로 다음 명령을 실행하여 라이브러리 설정을 확인하십시오.

    pkcs11-tool --module=/opt/oracle/extapi/64/hsm/ibm/pkcs11-grep11.so -I
    

    이 명령은 제조자 및 라이브러리에 대한 정보를 인쇄합니다. 예를 들면, 다음과 같습니다.

    Cryptoki version 2.40
    Manufacturer     IBM ...
    Library          GREP11 PKCS11 client ...
    

5. Hyper Protect Crypto Services PKCS #11 라이브러리 초기화

  1. 호스트 시스템의 명령행에서 다음 명령을 실행하십시오.

    docker exec -it oradb bash
    

    이 쉘은 후속 단계에서 oracle 사용자로 명령을 실행하기 위해 사용할 수 있습니다.

  2. 토큰을 초기화하려면 다음 명령을 실행하고 <your_api_key>을(를) 작성된 API 키로 대체하십시오.

    pkcs11-tool  --module /opt/oracle/extapi/64/hsm/ibm/pkcs11-grep11.so --init-token --label dbtoken --so-pin=<your_api_key>
    

    이 명령으로 다음과 같은 상태 메시지가 인쇄됩니다. 예를 들면, 다음과 같습니다.

    Using slot 0 with a present token (0x0)
    Token successfully initialized
    

Oracle Database TDE 설정 및 데이터 암호화

이제 데이터베이스 관리자의 역할에 대한 정보를 확인하십시오.

  1. 다음 행을 추가하여 '$ORACLE_HOME/network/admin' 디렉토리에 있는 'sqlnet.ora' 파일을 업데이트하십시오.

    encryption_wallet_location=(source=(method=hsm))
    

    이 작업을 수행하기 위해 예를 들어 다음과 같은 명령을 실행할 수 있습니다.

    echo "encryption_wallet_location=(source=(method=hsm))" >> $ORACLE_HOME/network/admin/sqlnet.ora
    

    'sqlnet.ora' 파일에 encryption_wallet_location에 대한 다른 설정이 포함되어 있지 않은지 확인하십시오.

  2. 다음 명령을 사용하여 키 저장소를 여십시오. <your_api_key>을(를) 작성된 API 키로 대체하십시오.

    export ORACLE_SID=<your SID, e.g. ORCLCDB>
    sqlplus / as sysdba
    SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "<your_api_key>" CONTAINER=ALL;
    
  3. 다음 명령을 사용하여 마스터 키를 작성하십시오. <your_api_key>을(를) 작성된 API 키로 대체하십시오.

    SQL> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY "<your_api_key>" WITH BACKUP CONTAINER=ALL;
    
  4. 다음 명령을 사용하여 암호화된 테이블스페이스를 작성하십시오.

    SQL> CREATE TABLESPACE encrypted_ts DATAFILE 'tbs1_data.dbf' SIZE 128K AUTOEXTEND ON NEXT 64K ENCRYPTION USING 'AES256' DEFAULT STORAGE(ENCRYPT);
    
  5. 설정을 확인하기 위해 암호화된 테이블스페이스에 테이블을 작성한 후 몇 가지 테스트 데이터를 삽입할 수 있습니다.

    SQL> CREATE TABLE tde_ts_test (id    NUMBER(10), data  VARCHAR2(50)) TABLESPACE encrypted_ts;
    SQL> INSERT INTO tde_ts_test VALUES (1, 'This is a secret!');
    SQL> COMMIT;
    SQL> SELECT * FROM TDE_TS_TEST;
    
  6. 암호화된 열이 포함된 테이블을 작성한 후 몇 가지 테스트 데이터를 삽입할 수도 있습니다.

    SQL> CREATE USER C##test IDENTIFIED BY test;
    SQL> GRANT UNLIMITED TABLESPACE TO C##test;
    SQL> CREATE TABLE C##test.tde_test (id NUMBER(10), data VARCHAR2(50) ENCRYPT);
    SQL> INSERT INTO C##test.tde_test VALUES (1, 'This is also a secret!');
    SQL> COMMIT;
    SQL> SELECT * FROM C##test.tde_test;
    
    # Verify encrypted tablespace and encrypted column
    SQL> SELECT TABLESPACE_NAME, ENCRYPTED FROM DBA_TABLESPACES;
    SQL> SELECT * FROM dba_encrypted_columns ;
    

다음 단계

이제 중요한 데이터가 암호화된 테이블스페이스 및 암호화된 열에 안전하게 저장됩니다. 또한 TDE 마스터 암호화 키는 보안 수준이 매우 높고 위조가 방지된 상태로 Hyper Protect Crypto Services에 보관됩니다.

이 튜토리얼에서는 Hyper Protect Crypto Services에서 Oracle Database TDE를 설정하는 방법에 대해 알아보았습니다.