|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ContentStream
The interface for the stream implementations of the CMS content types.
The stream support has been included into the iaik.cms package for providing an utility to handle large amounts of data which cannot be processed properly within the memory "as a whole". The idea behind the stream interface comes from the possibility of using the indefinite constructed method for BER encoding an OCTET_STRING instead of encoding it definite primitive. Remember that the ASN.1 type OCTET_STRING is used for encoding the content of an inherent EncapsulatedContentInfo object ( RFC 5652):
EncapsulatedContentInfo ::= SEQUENCE { eContentType ContentType, eContent [0] EXPLICIT OCTET STRING OPTIONAL } ContentType ::= OBJECT IDENTIFIER
0x04 <length> <data>Consider, for example the five data bytes
0x01 0xAB 0x23 0x7F 0xCA
and their
primitive definite encoding to:
0x04 0x05 0x01 0xAB 0x23 0x7F 0xCAHowever, this method may not be suitable for large data volumes when the data length is not known in advance. Since an octet string is not allowed to be indefinite primitive encoded (how to distinguish EOC octets from two adjacent 0x00 0x00 data bytes?), a BER encoding variant has to be used where whole the octet string is encoded as indefinite constructed octet string, being composed of a certain number of rather small primitive definite encoded octet string components. The length of each primitive component shall be set to a predefined blocksize:
0x24 0x80 0x04 <blocksize> <data> 0x04 <blocksize> <data> 0x04 <blocksize> <data> ... 0x00 0x00Of course, the last block may be shorter than the defined blocksize!
0x24 0x80 0x04 0x02 0x01 0xAB 0x04 0x02 0x23 0x7F 0x04 0x01 0xCA 0x00 0x00In this way, the general encoding procedure for the stream supporting classes of the iaik.cms package can be summarized as follows:
0x24 0x80
0x00 0x00
This procedure makes it possible to limit the data volumes actually processed within the memory to a reasonable small size!
This interface supplies some abstract methods that have to be implemented by any class
that represents the stream implementation of one of the several CMS content types.
Since any non-stream supporting class of the IAIK-CMS package implements the
Content
interface, which itself inherits from this
ContenStream interface, all non-stream supporting classes of the CMS package
implement the abstract methods of this interface, too.
Within the IAIK-CMS package, this interface is implemented for all six content
types specified by CMS (RFC 5652),
and for the CompressedData type ( RFC 3274):
Data
(stream implementation by DataStream
)
SignedData
(stream implementation by SignedDataStream
)
EnvelopedData
(stream implementation by EnvelopedDataStream
)
DigestedData
(stream implementation by DigestedDataStream
)
EncryptedData
(stream implementation by EncryptedDataStream
)
AuthenticatedData
(stream implementation by AuthenticatedDataStream
)
CompressedData
(stream implementation by CompressedDataStream
)
Implementations of this interface do not
represent the contentType
field of the CMS ContentInfo
structure. They represent the
ASN.1 structures defined by the Cryptographic Message Syntax (CMS)
(RFC 5652) for
the several CMS content types.
Implementations of this interface are instantiated for supplying values for the
content
field of the CMS ContentInfo
structure. Each
implementation shall implement the getContentType
method
allowing to query for the OID unequivocally identifying the implemented CMS content
type.
This OID value actually represents the value of the CMS ContentInfo
contentType field:
ContentInfo ::= SEQUENCE { contentType ContentType, content [0] EXPLICIT ANY DEFINED BY contentType }
ContentType ::= OBJECT IDENTIFIER
ContentInfoStream
,
DataStream
,
SignedDataStream
,
EnvelopedDataStream
,
DigestedDataStream
,
EncryptedDataStream
,
AuthenticatedDataStream
,
CompressedDataStream
Method Summary | |
---|---|
void |
decode(java.io.InputStream is)
Decodes the BER encoded data of the implemented CMS content type, supplied from an input stream. |
int |
getBlockSize()
Gets the block size defining the length of each definite primitive encoded octet string component. |
ObjectID |
getContentType()
Returns the OID of the implemented CMS content type. |
void |
setBlockSize(int blockSize)
Sets the block size for defining the length of each definite primitive encoded octet string component. |
ASN1Object |
toASN1Object()
Returns the content value of the implemented CMS content type as an ASN1Object. |
java.lang.String |
toString(boolean detailed)
Returns a string giving some - if requested - detailed information about the implemented CMS content type. |
Method Detail |
---|
ObjectID getContentType()
void decode(java.io.InputStream is) throws java.io.IOException, CMSParsingException
is
- the BER encoded CMS content type as input stream
java.io.IOException
- if an error occurs while reading the stream
CMSParsingException
- if an error occurs during the decoding processASN1Object toASN1Object() throws CMSException
CMSException
- if the ASN1Object could not be createdjava.lang.String toString(boolean detailed)
detailed
- whether or not to give detailed information about the implemented
CMS content type.
void setBlockSize(int blockSize)
blockSize
is smaller or equal to zero the
whole data is encoded as definite primitive octet string.
blockSize
- for defining the encoding scheme and setting the octet
string component length, if positiveint getBlockSize()
blockSize
is smaller or equal to zero the
whole data is encoded as definite primitive octet string.
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |