Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / Security / Cryptography / RC2.cs / 1 / RC2.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// RC2.cs
//
namespace System.Security.Cryptography {
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RC2 : SymmetricAlgorithm
{
protected int EffectiveKeySizeValue;
private static KeySizes[] s_legalBlockSizes = {
new KeySizes(64, 64, 0)
};
private static KeySizes[] s_legalKeySizes = {
new KeySizes(40, 1024, 8) // 1024 bits is theoretical max according to the RFC
};
//
// protected constructors
//
protected RC2() {
KeySizeValue = 128;
BlockSizeValue = 64;
FeedbackSizeValue = BlockSizeValue;
LegalBlockSizesValue = s_legalBlockSizes;
LegalKeySizesValue = s_legalKeySizes;
}
//
// public properties
//
public virtual int EffectiveKeySize {
get {
if (EffectiveKeySizeValue == 0) return KeySizeValue;
return EffectiveKeySizeValue;
}
set {
if (value > KeySizeValue) {
throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKSKS"));
} else if (value == 0) {
EffectiveKeySizeValue = value;
} else if (value < 40) {
throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKS40"));
} else {
if (ValidKeySize(value))
EffectiveKeySizeValue = value;
else
throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
}
}
}
public override int KeySize {
get { return KeySizeValue; }
set {
if (value < EffectiveKeySizeValue) throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKSKS"));
base.KeySize = value;
}
}
//
// public methods
//
new static public RC2 Create() {
return Create("System.Security.Cryptography.RC2");
}
new static public RC2 Create(String AlgName) {
return (RC2) CryptoConfig.CreateFromName(AlgName);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// RC2.cs
//
namespace System.Security.Cryptography {
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RC2 : SymmetricAlgorithm
{
protected int EffectiveKeySizeValue;
private static KeySizes[] s_legalBlockSizes = {
new KeySizes(64, 64, 0)
};
private static KeySizes[] s_legalKeySizes = {
new KeySizes(40, 1024, 8) // 1024 bits is theoretical max according to the RFC
};
//
// protected constructors
//
protected RC2() {
KeySizeValue = 128;
BlockSizeValue = 64;
FeedbackSizeValue = BlockSizeValue;
LegalBlockSizesValue = s_legalBlockSizes;
LegalKeySizesValue = s_legalKeySizes;
}
//
// public properties
//
public virtual int EffectiveKeySize {
get {
if (EffectiveKeySizeValue == 0) return KeySizeValue;
return EffectiveKeySizeValue;
}
set {
if (value > KeySizeValue) {
throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKSKS"));
} else if (value == 0) {
EffectiveKeySizeValue = value;
} else if (value < 40) {
throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKS40"));
} else {
if (ValidKeySize(value))
EffectiveKeySizeValue = value;
else
throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
}
}
}
public override int KeySize {
get { return KeySizeValue; }
set {
if (value < EffectiveKeySizeValue) throw new CryptographicException(Environment.GetResourceString("Cryptography_RC2_EKSKS"));
base.KeySize = value;
}
}
//
// public methods
//
new static public RC2 Create() {
return Create("System.Security.Cryptography.RC2");
}
new static public RC2 Create(String AlgName) {
return (RC2) CryptoConfig.CreateFromName(AlgName);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LinearKeyFrames.cs
- FixedSOMLineCollection.cs
- Interlocked.cs
- ObjectItemCollection.cs
- BinaryObjectInfo.cs
- ListItemParagraph.cs
- Ports.cs
- _KerberosClient.cs
- DataServiceSaveChangesEventArgs.cs
- SqlTriggerAttribute.cs
- OutputCacheProfile.cs
- BamlBinaryReader.cs
- ConditionCollection.cs
- embossbitmapeffect.cs
- HWStack.cs
- Camera.cs
- TypedTableHandler.cs
- XmlWellformedWriter.cs
- ExceptionHandlerDesigner.cs
- SelectedDatesCollection.cs
- NameValueSectionHandler.cs
- XmlWrappingReader.cs
- Fx.cs
- ActivatedMessageQueue.cs
- HttpCacheVaryByContentEncodings.cs
- DetailsViewDeleteEventArgs.cs
- FixedSOMPage.cs
- CaseInsensitiveOrdinalStringComparer.cs
- LoginName.cs
- PropagationProtocolsTracing.cs
- ThicknessAnimationBase.cs
- CursorConverter.cs
- NameValuePermission.cs
- CryptographicAttribute.cs
- StringCollection.cs
- SettingsContext.cs
- FontStyleConverter.cs
- TransformerInfo.cs
- CornerRadius.cs
- BoolExpressionVisitors.cs
- StrongNamePublicKeyBlob.cs
- EditorAttribute.cs
- FamilyCollection.cs
- XmlDataDocument.cs
- ExpressionWriter.cs
- StyleCollectionEditor.cs
- ProfileSection.cs
- SelectionProcessor.cs
- MessageEncodingBindingElementImporter.cs
- ListBoxItemAutomationPeer.cs
- XmlDigitalSignatureProcessor.cs
- ComponentResourceKey.cs
- StoreAnnotationsMap.cs
- FixedPageStructure.cs
- PolyLineSegment.cs
- ScriptingJsonSerializationSection.cs
- CalendarDay.cs
- TranslateTransform3D.cs
- FixedPageProcessor.cs
- CheckBox.cs
- _Win32.cs
- CollectionBase.cs
- FilterFactory.cs
- AddInDeploymentState.cs
- ModelItem.cs
- EmptyReadOnlyDictionaryInternal.cs
- ToolBarButtonDesigner.cs
- ToolStripRendererSwitcher.cs
- SlipBehavior.cs
- XslException.cs
- XmlSchemaSimpleTypeRestriction.cs
- EdmItemCollection.cs
- Peer.cs
- ItemCheckEvent.cs
- ToolStripProgressBar.cs
- PlaceHolder.cs
- BaseTemplateParser.cs
- ResourceExpressionBuilder.cs
- BinaryObjectInfo.cs
- TextPointerBase.cs
- ResourceManager.cs
- SerializationTrace.cs
- BasicCellRelation.cs
- DesignerContextDescriptor.cs
- ValidationSummary.cs
- LinkConverter.cs
- URLIdentityPermission.cs
- WmiInstallComponent.cs
- KnownAssembliesSet.cs
- AdapterDictionary.cs
- PatternMatcher.cs
- HtmlUtf8RawTextWriter.cs
- ResourcePart.cs
- RowParagraph.cs
- QueryActivatableWorkflowsCommand.cs
- Error.cs
- ConstantSlot.cs
- GraphicsPath.cs
- PropertyMappingExceptionEventArgs.cs
- CounterNameConverter.cs