如何将 public 指数属性更改为字节数组
How to change public exponent attribute to be a byte array
我正在使用 Luna G5 HSM,需要生成密钥对。我有如下代码,但是有一个错误说我需要将 public 指数属性更改为字节数组,但我不知道如何修改这部分,任何帮助将不胜感激。
templatePub = new CryptokiCollection()
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS,CryptokiObject.CKO_PUBLIC_KEY))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_TOKEN, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_SENSITIVE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_EXTRACTABLE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_ENCRYPT, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_VERIFY, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_WRAP, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_DERIVE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_MODULUS_BITS, 2048))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_PUBLIC_EXPONENT, 0x010001))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_ID, "60"));
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_LABEL, "public key"))
templatePri = new CryptokiCollection()
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_PRIVATE_KEY))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_TOKEN, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_SENSITIVE, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_EXTRACTABLE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_DECRYPT, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_SIGN, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_UNWRAP, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_DERIVE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_ID, "60"))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_LABEL, "private key"))
用这个替换 public 指数线:
templatePub.Add(New ObjectAttribute(ObjectAttribute.CKA_PUBLIC_EXPONENT, &H10001))
我正在使用 Luna G5 HSM,需要生成密钥对。我有如下代码,但是有一个错误说我需要将 public 指数属性更改为字节数组,但我不知道如何修改这部分,任何帮助将不胜感激。
templatePub = new CryptokiCollection()
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS,CryptokiObject.CKO_PUBLIC_KEY))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_TOKEN, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_SENSITIVE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_EXTRACTABLE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_ENCRYPT, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_VERIFY, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_WRAP, true))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_DERIVE, false))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_MODULUS_BITS, 2048))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_PUBLIC_EXPONENT, 0x010001))
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_ID, "60"));
templatePub.Add(new ObjectAttribute(ObjectAttribute.CKA_LABEL, "public key"))
templatePri = new CryptokiCollection()
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_PRIVATE_KEY))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_TOKEN, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_SENSITIVE, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_EXTRACTABLE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_DECRYPT, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_SIGN, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_UNWRAP, true))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_DERIVE, false))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_ID, "60"))
templatePri.Add(new ObjectAttribute(ObjectAttribute.CKA_LABEL, "private key"))
用这个替换 public 指数线:
templatePub.Add(New ObjectAttribute(ObjectAttribute.CKA_PUBLIC_EXPONENT, &H10001))