Key interface parsing in Java _java

Source: Internet
Author: User
Tags serialization

The interface implements serialization, declared as public interface Key extends Serializable

The key is the top-level interface for all keys. It defines the features that are shared by all key objects. All keys have three characteristics:

①, algorithm

This is the key algorithm for the key. Key algorithms are usually cryptographic or asymmetric operation algorithms (such as DSA or RSA) that will be used with those algorithms and associated algorithms (such as MD5 and Rsa,sha-1 and RSA, Raw DSA, and so on). Gets the name of the key algorithm using the Getalgorithm method.

②, coded form

This is the external encoding of the key, which is used when the standard representation of the key is required outside the Java virtual machine and when the key is transferred to some other part. The key is encoded according to a standard format (such as X.509 subjectpublickeyinfo or pkcs#8) and is returned using the Getencoded method. Note: ASN.1 type subjectpublickeyinfo syntax is defined as follows:

Copy Code code as follows:

Subjectpublickeyinfo:: = SEQUENCE {algorithm algorithmidentifier, Subjectpublickey BIT STRING}
Algorithmidentifier:: = SEQUENCE {algorithm OBJECT IDENTIFIER, parameters any DEFINED by algorithm OPTIONAL}

③, format

This is the name of the encoded key's format. It is returned by the GetFormat method.

The key is usually obtained through a key generator, a certificate, or various Identity classes used to manage the key. The key can also be obtained from the key specification (the transparent representation of the underlying keying material) by using the key factory (see Keyfactory).

The key should use Keyrep as its serialized representation. Note that the serialized Key may contain sensitive information that should not be displayed in an untrusted environment. For more information, see the security appendix for the serialization specification.

1, field:
The static final long Serialversionuid is set to indicate a class fingerprint that is compatible with the previous class version serialization. 2. Detailed method:

①string Getalgorithm () returns the standard algorithm name for this key. For example, "DSA" indicates that this key is a DSA key.

②string GetFormat () returns the basic encoded format of this key, or null if the key does not support encoding. If there is a ASN.1 specification for this key, the basic encoding format is named according to the appropriate ASN.1 data format. For example, the ASN.1 data format name for the public key is subjectpublickeyinfo (defined by the X.509 standard), in which case the returned format is "X.509". Similarly, the ASN.1 data format name for the private key is privatekeyinfo (defined by a PKCS #8 standard), in which case the returned format is "Pkcs#8".

③byte[] getencoded () returns the key in the basic encoded format, or null if the key does not support encoding.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.