CloudHSM에서 특정 crypto 함수만 허용하도록 다른 사용자와 키를 공유하려면 어떻게 해야 합니까?

8분 분량
0

한 사용자가 키를 래핑하고 다른 사용자가 동일한 해당 키만 언래핑할 수 있도록 하려면 어떻게 해야 합니까?

간략한 설명

AWS CloudHSM 클러스터의 HSM에 저장된 키에 대한 사용자의 액세스를 공유할 수 있습니다. 그러나 이 경우 사용자에게 모든 권한(예: 래핑, 언래핑, 암호화, 암호 해독)에 대한 액세스를 허용할 수 있습니다.

해결 방법

키를 내보내고 다시 가져옵니다(2번 수행). 키 속성을 가져올 때 래핑 또는 언래핑 권한이 변경됩니다. 그런 다음, 래핑 또는 언래핑을 위한 함수를 수행하도록 다른 사용자와 키를 공유합니다.

cloudhsm_mgmt_util 명령줄 도구를 사용하여 클러스터의 모든 사용자 나열

cloudhsm_mgmt_util 도구 사용을 시작하기 전에 CloudHSM Management Utility(CMU) 시작하기를 참조하세요.

다음과 비슷한 listUsers 명령을 실행합니다.

Number of users found:8

    User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
         1              CO              admin                                    NO               0               NO
         2              AU              app_user                                 NO               0               NO
         3              CO              officer1                                 NO               0               NO
         4              CO              crypto_user1                             NO               0               NO
         5              CO              crypto_user2                             NO               0               NO
         6              CU              crypto_user3                             NO               0               NO
         7              CU              crypto_user4                             NO               0               NO
         8              CU              crypto_user5                             NO               0               NO

crypto_user1 및 crypto_user2는 CO(Crypto Officer)이므로 이들은 키를 소유할 수 없습니다. 다음 예제에서는 crypto 사용자의 crypto_user3, crypto_user4 및 crypto_user5를 사용합니다.

key_mgmt_util 명령줄 도구에서 genSymKey 명령을 사용하여 HSM에서 AES 대칭 키 생성

crypto_user3을 사용하여 HSM에 로그인하고 key_mgmt_util 도구를 사용하여 암호화 및 암호 해독을 위한 대칭 키를 생성합니다. genSymKey 명령을 사용하여 다음과 비슷한 rootKey 레이블의 AES 256비트 키를 생성합니다.

Command:  genSymKey -t 31 -s 32 -l rootKey

        Cfm3GenerateSymmetricKey returned: 0x00 : HSM Return: SUCCESS

        Symmetric Key Created.  Key Handle: 786512

        Cluster Error Status
        Node id 3 and err state 0x00000000 : HSM Return: SUCCESS
        Node id 4 and err state 0x00000000 : HSM Return: SUCCESS

이 예제에서는 키 핸들 786512를 사용합니다.

genSymKey 명령을 사용하여 세션 키를 생성하고 디스크 키 래핑 및 HSM으로 다시 언래핑

-sess 파라미터를 사용하여 세션 키를 생성합니다. 세션 창은 열려 있고, 연결은 설정되어 있으며, crypto_user3은 로그인한 상태입니다. genSymKey 명령에서 sessionKey 레이블을 사용하여 나중에 이 키를 식별합니다.

Command:  genSymKey -t 31 -s 32 -sess -l sessionKey

        Cfm3GenerateSymmetricKey returned: 0x00 : HSM Return: SUCCESS

        Symmetric Key Created.  Key Handle: 786511

        Cluster Error Status
        Node id 3 and err state 0x00000000 : HSM Return: SUCCESS
        Node id 4 and err state 0x00000000 : HSM Return: SUCCESS

이 예제에서는 세션 키 786511에서 wrapKeyunWrapKey 작업을 수행합니다.

참고: 세션이 닫히면 세션 키는 삭제됩니다.

wrapKey 명령을 사용하여 디스크로 키 쓰기 및 키 보안 유지

로컬 드라이브의 파일로 대칭 키 786512를 내보냅니다. 대칭 키 786512는 세션 키 786511로 암호화됩니다. 이러한 암호화를 사용하면 HSM 외부에서 대칭 키 786512는 일반 텍스트로 저장되지 않습니다. 로컬 드라이브에 rootKey를 래핑한 후에 unWrapKey 명령을 사용하여 HSM으로 다시 rootKey 786512를 가져옵니다. HSM 내부에서 키 핸들이 다른 rootKey의 복사본을 생성합니다. 그런 다음, 키 사용 방법을 제한하도록 rootKey 복사본의 속성을 변경합니다.

이 예제에서는 sessionKey 786511이 rootKey 786512를 래핑하고, root.key 파일로 로컬 드라이브에 저장합니다.

Command:  wrapKey -k 786512 -w 786511 -out root.key

        Key Wrapped.

        Wrapped Key written to file "root.key length 312
        
        Cfm2WrapKey returned: 0x00 : HSM Return: SUCCESS

참고: ls 명령을 사용하여 로컬 디렉터리에서 래핑된 키를 볼 수 있습니다.

unWrapKey 명령을 사용하여 HSM에 새 핸들로 키 다시 가져오기

unWrapKey 명령을 사용하여 키 root.key를 HSM에 다시 가져옵니다. 이 예제에서는 새 키 핸들, 786523 및 786524를 생성합니다.

중요: 이 단계를 2번 수행합니다.

Command:  unWrapKey -f root.key -w 786511

        Cfm3UnWrapKey returned: 0x00 : HSM Return: SUCCESS

        Key Unwrapped.  Key Handle: 786523

        Cluster Error Status
        Node id 3 and err state 0x00000000 : HSM Return: SUCCESS
        Node id 4 and err state 0x00000000 : HSM Return: SUCCESS

Command:  unWrapKey -f root.key -w 786511

        Cfm3UnWrapKey returned: 0x00 : HSM Return: SUCCESS

        Key Unwrapped.  Key Handle: 786524

        Cluster Error Status
        Node id 3 and err state 0x00000000 : HSM Return: SUCCESS
        Node id 4 and err state 0x00000000 : HSM Return: SUCCESS

키 핸들 확인 및 속성 지정

cloudhsm_mgmt_util 명령을 사용하여 crypto_user3에서 소유한 모든 키 핸들을 확인합니다. 이 예제에서는 rootKey 786512, 가져온 키 핸들 786523 및 가져온 키 핸들 786524를 기록합니다. crypto_user3에 대해 사용자 ID 60을 입력하여 모든 키의 해시를 계산하지 않음을 표시합니다. 그러면 HSM에서 사용하는 키 핸들을 볼 수 있습니다. findAllKeys 명령으로 표시되는 키 핸들은 암호화 측면에서 동일합니다(rootKey 786512와 속성이 동일함).

참고: 세션 키 핸들 786511은 표시되지 않습니다. 이 키 핸들은 세션 수명 기간에만 유지되기 때문입니다.

aws-cloudhsm>findAllKeys 6 0
Keys on server 0(172.31.3.131):
Number of keys found 3
number of keys matched from start index 0::3
786512,786523,786524
findAllKeys success on server 0(172.31.3.131)
Keys on server 1(172.31.4.209):
Number of keys found 3
number of keys matched from start index 0::3
786512,786523,786524
findAllKeys success on server 1(172.31.4.209)

이 예제에서는 키 786524 래핑을 위한 하나의 키 핸들과 키 786523 언래핑을 위한 다른 키 핸들을 지정합니다.

cloudhsm_mgmt_util을 setAttribute 명령과 함께 사용하여 키의 래핑/언래핑 속성 구성

setAttribute 명령에는 키 핸들 및 속성 ID가 필요합니다 속성 ID는 키 속성과 관련된 정수를 참조합니다. listAttibutes 명령을 사용하여 이러한 항목을 나열합니다. aws-cloudhsm>setAttribute 명령에서 키 786523을 사용하여 OBJ_ATTR_WRAP 속성 값을 2620으로 설정합니다.

aws-cloudhsm>setAttribute 786523 262 0
*************************CAUTION********************************
This is a CRITICAL operation, should be done on all nodes in the
cluster. Cav server does NOT synchronize these changes with the
nodes on which this operation is not executed or failed, please
ensure this operation is executed on all nodes in the cluster.
****************************************************************

Do you want to continue(y/n)?y
setAttribute success on server 0(172.31.3.131)
setAttribute success on server 1(172.31.4.209)

그런 다음, setAttribute 명령에서 키 786524를 사용하여 OBJ_ATTR_UNWRAP 속성 값을 2630으로 설정합니다. OBJ_ATTR_WRAP 속성은 262입니다.

aws-cloudhsm>setAttribute 786524 263 0
*************************CAUTION********************************
This is a CRITICAL operation, should be done on all nodes in the
cluster. Cav server does NOT synchronize these changes with the
nodes on which this operation is not executed or failed, please
ensure this operation is executed on all nodes in the cluster.
****************************************************************

Do you want to continue(y/n)?y
setAttribute success on server 0(172.31.3.131)
setAttribute success on server 1(172.31.4.209)

이제 래핑과 언래핑 모두가 가능한 rootKey 786512, 래핑만 가능한 키 786524, 언래핑만 가능한 키 786523가 구성됩니다.

이 예제에서는 crypto_user3이 786512, 786523, 786524 키를 소유하고 있으며, 키는 공유되지 않습니다.

키 래핑을 테스트하여 모든 속성이 올바르게 설정되었는지 확인

key_mgmt_util 명령줄 도구에서 wrapKey 명령을 실행합니다.

언래핑을 위해 지정한 키 핸들 786523을 사용하여 rootKey 786512를 로컬 드라이브에 래핑합니다.

그런 다음, 래핑을 위해 지정한 키 핸들 786524를 사용하여 rootKey 786512를 로컬 드라이브에 래핑합니다.

Command:  wrapKey -k 786512 -w 786523 -out wrapped.key

        Cfm2WrapKey returned: 0xb3

        HSM Error: This operation violates the current configured/FIPS policies

Command:  wrapKey -k 786512 -w 786524 -out wrapped.key

        Key Wrapped.

        Wrapped Key written to file "wrapped.key.test length 309

        Cfm2WrapKey returned: 0x00 : HSM Return: SUCCESS

이 예제에서는 HSM 오류에 표시된 대로, 래핑 키 786523에서 오류가 발생합니다. HSM 오류는 OBJ_ATTR_WRAP 래핑 속성이 0으로 설정되었기 때문입니다.

getAttribute 명령을 실행하여 키 속성 값이 false로 설정되었는지 확인

getAttribute 명령은 key_mgmt_utilcloudhsm_mgmt_util 도구를 사용합니다. 두 명령줄 도구에서 이 구문은 서로 달라도 각각 속성 결과를 표시합니다. 이 예제에서는 cloudhsm_mgmt_util을 사용합니다. 속성을 파일에 저장하지 않아도 되기 때문입니다.

aws-cloudhsm>getAttribute 786523 262
Attribute Value on server 0(172.31.3.131):
OBJ_ATTR_WRAP
0x00000000

Attribute Value on server 1(172.31.4.209):
OBJ_ATTR_WRAP
0x00000000

다른 사용자와 키 공유

cloudhsm_mgm_util 명령을 사용하여 crypto_user4(사용자 ID 7) 및 crypto_user5(사용자 ID 8)와 키를 공유합니다. 언래핑 키 786523을 crypto_user4와 공유하고, 래핑 키 786524를 crypto_user5와 공유합니다. 그러면 이러한 사용자(crypto_user4 및 crypto_user5)는 암호화 함수에 대해 키를 사용할 수 있지만, 키 속성의 삭제, 내보내기, 공유, 공유 해제 또는 변경을 수행할 수 없습니다. 이를 통해 사용자의 crypto_user4 및 crypto_user5는 키 속성을 지정할 때 crypto_user3에서 지정한 작업에만 키를 사용할 수 있습니다.

aws-cloudhsm>shareKey 786523 7 1
*************************CAUTION********************************
This is a CRITICAL operation, should be done on all nodes in the
cluster. Cav server does NOT synchronize these changes with the
nodes on which this operation is not executed or failed, please
ensure this operation is executed on all nodes in the cluster.
****************************************************************

Do you want to continue(y/n)?y
shareKey success on server 0(172.31.3.131)
shareKey success on server 1(172.31.4.209)


aws-cloudhsm>shareKey 786524 8 1
*************************CAUTION********************************
This is a CRITICAL operation, should be done on all nodes in the
cluster. Cav server does NOT synchronize these changes with the
nodes on which this operation is not executed or failed, please
ensure this operation is executed on all nodes in the cluster.
****************************************************************

Do you want to continue(y/n)?y
shareKey success on server 0(172.31.3.131)
shareKey success on server 1(172.31.4.209)

디스크 및 HSM 사이에서 wrapKey 명령을 사용하여 래핑 및 언래핑 기능 테스트

crypto_user4(사용자 ID 7)가 crypto_user3에서 래핑된 키를 언래핑할 수 있는지 테스트합니다.

키 crypto_user3 및 crypto_user_4는 암호화 측면에서 동일하며, 래핑 및 언래핑을 위한 함수를 독립적으로 수행하는 데 사용됩니다.

Command:  unWrapKey -f wrapped.key -w 786523

        Cfm3UnWrapKey returned: 0x00 : HSM Return: SUCCESS

        Key Unwrapped.  Key Handle: 1048669

        Cluster Error Status
        Node id 3 and err state 0x00000000 : HSM Return: SUCCESS
        Node id 4 and err state 0x00000000 : HSM Return: SUCCESS

관련 정보

CloudHSM 클러스터 활성화

AWS 공식
AWS 공식업데이트됨 3년 전
댓글 없음

관련 콘텐츠