关键对象和关键规范(KeySpecs)是关键数据的两种不同表示。
密码使用密钥对象来初始化他们的加密算法,但密钥可能需要转换为更便携的格式进行传输或存储。
密钥的透明表示意味着您可以通过相应规范类中定义的get方法之一单独访问每个密钥材料值。
For example, DSAPrivateKeySpec defines getX, getP, getQ, and getG methods, to access the private key x, and the DSA algorithm parameters used to calculate the key(the prime p, the sub-prime q, and the base g).
如果密钥被存储在硬件设备上,其说明书可以包含有助于识别在device.This表示的键是对比不透明表示,通过键接口所定义的信息,在其中无法直接访问关键材料字段。换句话说,“不透明”表示使您能够有限地访问密钥 - 只有Key接口定义的三种方法:getAlgorithm,getFormat和getEncoded。
密钥可以按照特定于算法的方式或与算法无关的编码格式(如ASN.1)指定。
For example, a DSA private key may be specified by its components x, p, q, and g (eg: DSAPrivateKeySpec), or it may be specified using its DER encoding (eg: PKCS8EncodedKeySpec).
的的KeyFactory和SecretKeyFactory类可用于即,按键和KeySpecs之间不透明和透明键表示之间进行转换。
参考,并提供更多的细节: https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html#KeySpecs