2014-01-29 1 views
1

PKCS # 11 호환 암호화 토큰을 사용하여 AES 키를 생성하고 화면에 값을 표시하고 싶습니다.IAIK PKCS # 11 래퍼를 통해 AES 키를 생성하고 해당 값을 표시하십시오.

그 목적을 위해 IAIK PKCS # 11 래퍼를 사용하고 싶습니다.

IAIK 패키지와 함께 제공된 예제로 키를 생성하려고했지만 성공하지 못했습니다. 키가 생성되었지만 키의 값을 볼 수 없습니다. 화면에 표시하기 위해 키 값을 확인하려면 어떻게해야합니까? 다음과 같이

Module pkcs11Module = null; 
pkcs11Module = Module.getInstance("pkcs11.dll"); 

Session session = null; 
pkcs11Module.initialize(null); 

Slot[] slots = pkcs11Module.getSlotList(Module.SlotRequirement.TOKEN_PRESENT); 

if (slots.length == 0) { 
    output_.println("No slot with present token found!"); 
    throw new TokenException("No token found!"); 
} 

Slot selectedSlot; 
// slot 0 
selectedSlot = slots[0]; 

Token token = selectedSlot.getToken(); 

session = token.openSession(Token.SessionType.SERIAL_SESSION, Token.SessionReadWriteBehavior.RW_SESSION, null, null); 

session.login(Session.UserType.USER, "12345678".toCharArray()); 

Mechanism keyGenerationMechanism = Mechanism.get(PKCS11Constants.CKM_AES_KEY_GEN); 

AESSecretKey aesKey = new AESSecretKey(); 
aesKey.getValueLen().setLongValue(new Long(32)); 

AESSecretKey aesKeyNew = (AESSecretKey) session.generateKey(keyGenerationMechanism, aesKey); 
output_.println("the AES Key is: "); 
output_.println(aesKeyNew.toString()); 

session.closeSession(); 
pkcs11Module.finalize(null); 

결과는 다음과 같습니다 :

여기 내 코드입니다

the AES Key is: 
    Object Class: Secret Key 
    Token: false 
    Private: false 
    Modifiable: true 
    Label: <NULL_PTR> 
    Key Type: AES 
    ID: <NULL_PTR> 
    Start Date: <NULL_PTR> 
    End Date: <NULL_PTR> 
    Derive: true 
    Local: true 
    Key Generation Mechanism: CKM_AES_KEY_GEN 
    Allowed Mechanisms: <Attribute not present> 
    Sensitive: false 
    Encrypt: true 
    Decrypt: true 
    Sign: false 
    Verify: false 
    Wrap: true 
    Unwrap: true 
    Extractable: true 
    Always Sensitive: false 
    Never Extractable: true 
    Check Value: <Attribute not present> 
    Wrap With Trusted: <Attribute not present> 
    Trusted: <Attribute not present> 
    Wrap Template: <Attribute not present> 
    Unwrap Template: <Attribute not present> 
    Value (hex): <NULL_PTR> 
    Value Length (dec): 0 

는 값 (16 진수)이 : 내가보고 화면에 표시 할 것인지. 암호화 토큰의 특정 구성에 관한 것입니까? 다른 토큰을 사용하면이 값을 볼 수 있습니다.

답변

0

PKCS # 11 속성 CKA_SENSITIVE을 false로 설정하면 값을 볼 수 있어야합니다. 그러나 토큰을 사용하여 값을 추출 할 수는 없습니다. 이러한 종류의 토큰 대부분은 PKCS # 11을 완전히 구현하지 않으며 특정 작업 만 허용합니다. 이것이 사실이라면 다음 false로 CKA_SENSITIVE를 설정하는 것이 가능하지 않아야하지만

나는 제조업체를 추적 (또는 가능하면, 개발자) 토큰을 물어 것입니다 ... 당신을 위해입니다 토큰에 의해 구현 된 특정 기능에 대해.