Package ptolemy.actor.lib.security
Class SymmetricCrypto
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.security.SymmetricCrypto
-
- All Implemented Interfaces:
java.lang.Cloneable,Actor,Executable,FiringsRecordable,Initializable,TypedActor,Changeable,Debuggable,DebugListener,Derivable,Instantiable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class SymmetricCrypto extends TypedAtomicActor
Encrypt or decrypt an unsigned byte array using a symmetric cryptography.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Hokeun Kim
- Pt.AcceptedRating:
- Yellow (hokeunkim)
- Pt.ProposedRating:
- Green (hokeunkim)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description StringParameteralgorithmThe cryptography algorithm to be used for this actor.StringParametercipherModeThe cipher mode to be used for the cipher.TypedIOPorterrorThe error (e.g.TypedIOPortinputThe input data (for encrypt mode) or encrypted data (for decrypt mode).PortParameterkeyThe key to be used by this actor to encrypt/decrypt the data.StringParametermacAlgorithmThe secure hash algorithm for message authentication code (MAC) to be used for this actor.StringParameteroperationModeThe operation mode of the cipher, either encrypt or decrypt.TypedIOPortoutputThe encrypted data (for encrypt mode) or decrypted data (for decrypt mode).StringParameterpaddingThe padding to be used for the cipher.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SymmetricCrypto(CompositeEntity container, java.lang.String name)Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattributeChanged(Attribute attribute)Override the base class to reinitialize the state if the operationMode, algorithm, cipherMode, or padding parameter is changed.voidfire()If there is a token on the input port, this method takes the data from the input and encrypts the data based on the algorithm, provider, mode and padding using the key read in from the key port.voidinitialize()Override the base class to initialize the index.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
key
public PortParameter key
The key to be used by this actor to encrypt/decrypt the data.
-
operationMode
public StringParameter operationMode
The operation mode of the cipher, either encrypt or decrypt.
-
algorithm
public StringParameter algorithm
The cryptography algorithm to be used for this actor.
-
cipherMode
public StringParameter cipherMode
The cipher mode to be used for the cipher.
-
padding
public StringParameter padding
The padding to be used for the cipher.
-
macAlgorithm
public StringParameter macAlgorithm
The secure hash algorithm for message authentication code (MAC) to be used for this actor.
-
input
public TypedIOPort input
The input data (for encrypt mode) or encrypted data (for decrypt mode).
-
output
public TypedIOPort output
The encrypted data (for encrypt mode) or decrypted data (for decrypt mode).
-
error
public TypedIOPort error
The error (e.g. integrity check error for MAC)
-
-
Constructor Detail
-
SymmetricCrypto
public SymmetricCrypto(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the given container and name.- Parameters:
container- The container.name- The name of this actor.- Throws:
IllegalActionException- If the actor cannot be contained by the proposed container.NameDuplicationException- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Override the base class to reinitialize the state if the operationMode, algorithm, cipherMode, or padding parameter is changed.- Overrides:
attributeChangedin classNamedObj- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- Not thrown in this base class.
-
fire
public void fire() throws IllegalActionExceptionIf there is a token on the input port, this method takes the data from the input and encrypts the data based on the algorithm, provider, mode and padding using the key read in from the key port. This processed data is then sent on the output port. All parameters should be the same as the corresponding decryption actor. This method calls javax.crypto.Cipher.init() with the value of the key.- Specified by:
firein interfaceExecutable- Overrides:
firein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If thrown by base class.
-
initialize
public void initialize() throws IllegalActionExceptionOverride the base class to initialize the index.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If the parent class throws it, or if the values parameter is not a row vector, or if the fireAt() method of the director throws it, or if the director does not agree to fire the actor at the specified time.
-
-