Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Bring to CoreCLR the SecureString implementation from CoreFx. #7884

Merged
merged 4 commits into from
Oct 31, 2016

Conversation

AlexGhiondea
Copy link

Once this is checked in there is work remaining in CoreFx:

  • Remove the SecureString implementation from CoreFx and type-forward to this
  • Remove the implementation of CryptographicException and type-forward to this

@AlexGhiondea
Copy link
Author

/cc @JeremyKuhne @jkotas

Copy link
Member

@JeremyKuhne JeremyKuhne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use BCLDebug, use Debug.Assert to keep the code aligned.


private unsafe void InitializeSecureString(char* value, int length)
{
BCLDebug.Assert(length >= 0, $"Expected non-negative length, got {length}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use Debug.Assert

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - yes! When I originally ported this, your change was not there :).

Will change it!

// Make sure the requested capacity doesn't exceed SecureString's defined limit
if (capacity > MaxLength)
{
throw new ArgumentOutOfRangeException("capacity", SR.ArgumentOutOfRange_Capacity);
Copy link

@justinvp justinvp Oct 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: nameof(capacity)? (I see there are some other uses of nameof in this change, so presumably this language feature can be used in corelib.)

<Member Name="MakeReadOnly" />
<Member Name="RemoveAt(System.Int32)" />
<Member Name="SetAt(System.Int32,System.Char)" />
</Type>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about SecureStringMarshal?

namespace System.Security.Cryptography
{
[Serializable]
public class CryptographicException : SystemException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are we now exposing CryptographicException from coreclr as well? Presumably it needs to be added to model.xml as well then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added them both to model.xml.

@AlexGhiondea AlexGhiondea merged commit 8c64177 into dotnet:master Oct 31, 2016
@AlexGhiondea AlexGhiondea deleted the Port_SecureString branch October 31, 2016 20:06
@karelz karelz modified the milestone: 2.0.0 Aug 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants