iaik.asn1
Interface EncodeListener
- All Superinterfaces:
- EventListener
- All Known Implementing Classes:
- SignerInfo, DigestedDataStream
- public interface EncodeListener
- extends EventListener
Interface to be implemented for supplying relevant information actually during
the encoding process.
Implementing this interface may be useful in situations, where data to be
encoded is not known before the encoding actually is performed. Imaging, for
instance, some structure that shall be encoded as an ASN.1 SEQUENCE object having
an OCTET_STRING as one of its components. Imagine furthermore, that the byte value
supplying the contents of the OCTET_STRING component is not known at beginning of the
encoding procedure. When writing the toASN1Object
method
of such a structure, use an empty OCTET_STRING for the not-yet known byte value, and
implement the encodeCalled
method to set the
OCTET_STRING value actually during the encoding is performed, e.g.:
class xxx implements EncodeListener {
...
byte[] value;
...
public ASN1Object toASN1Object() throws CodingException {
SEQUENCE seq = new SEQUENCE();
...
// create an empty octet string and register as encode listener
OCTET_STRING oct = OCTET_STRING();
oct.addEncodeListener(this, 1);
}
...
// implement the encodeCalled method for setting the value during the
// encoding actually is performed
public void encodeCalled(ASN1Object o, int id) throws CodingException {
...
o.setValue(value);
}
...
}
Now, when calling DerCoder.encode(xxx.toASN1Object())
for performing the
DER encoding, the
addEncodeListener
method of the ASN1Object
class is used for registering
the calling instance of the xxx
class to be notified when the
OCTET_STRING component actually has to be encoded. Later, the programm execution will
jump to the encodeCalled
method of the xxx
instance for
obtaining the OCTET_STRING value. The encode
method of the OCTET_STRING
instance itself will be executed not before the encodeCalled
methods
of all registeres listeners have been executed.
Within the IAIK-JCE library, the EncodeListener utility is used for the stream
implementations of the several PKCS#7 content types, where the raw data to be
processed - e.g. signed for the example of the SignedData
type -
is supplied from an input stream that is not read before the encoding actually is
performed. Since the, for instance, encryptedDigest
value of an
inherent SigenrInfo
depends on the data supplied from the stream,
it cannot be calculated before the stream has been read, and therefore has
been set during the encoding. For that reason, the SignerInfo
class implemets the EncodeListener interface.
- Version:
- File Revision 15
- See Also:
ASN1Object
Method Summary |
void |
encodeCalled(ASN1Object o,
int id)
Method to be implemented for being called during the encoding procedure.
|
encodeCalled
public void encodeCalled(ASN1Object o,
int id)
throws CodingException
- Method to be implemented for being called during the encoding procedure.
Use this method for setting specific properties of the supplied
ASN1Object actually during the encoding is performed. If the EncodeListener
wishes to be notified about the encoding process of more than only one object,
use different id
values to distinguish between the several objects.
- Parameters:
o
- the ASN1Object to be supplied with information during the encoding
processid
- an id that may be used to listen for more than only one object
encodings- Throws:
CodingException
- if an error occurs during the encoding procedure
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).
|
PREV CLASS
NEXT CLASS |
FRAMES
NO FRAMES |
SUMMARY: INNER | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD |
IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK