Code Monkey home page Code Monkey logo

entityframeworkcore.encryptcolumn's People

Contributors

emrekizildas avatar osaleem303 avatar sametkahraman avatar svidem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entityframeworkcore.encryptcolumn's Issues

Error: You should create encryption provider. (Parameter 'encryptionProvider')

I'm on MVC .Net Core 3.1 & EFCore using EntityFrameworkCore.EncryptColumn Version 3.1.0

I'm getting the following error when I create a migration on an existing table in my database.
Error: You should create encryption provider. (Parameter 'encryptionProvider')

Currently my DbContext looks thusly (the key is just a random GUID I generated for testing purposes):
image

image

I have DTO with the property SSN
image

The project builds, but again the error happens I create the migration. As far as I understand, isn't the provider being created when the Context is newed-up, or on application start?

Null IV?

Is this code using a null IV?

I don't see where you read/write the IV anywhere... this doesn't seem right to me... seems like the IV is just null.

Am I missing something?

The [EncryptColumn] attribute cannot be used in netstandard 2.0 projects

Often the data-models are not located into the same assembly that contains the DbContext.
That "datamodels assembly" usually tends to have a lower framework compatibility level (i.e. netstandard 2.0) than the assembly containing the DbContext (which have no less than net6.0).
In order to solve this problem, I suggest to move the attribute [EncryptColumn] (and other netstandard 2.0-compliant abstractions) into another, dedicated package "EntityFrameworkCore.EncryptColumn.Abstractions", and/or implement FluentAPI like suggested in #4

Apply EncryptColumn with FluentAPI

I define my column attributes in a different namespace than my model classes. Is it possible to use FluentAPI to set the EncryptColumn setting?

Security problem with the IV AES

Since the library is always using the same IV, is potentially fragile in terms of security.

byte[] iv = new byte[16];

Here always the IV vector is initialized to the same value. What it should be, every encrypted value must have a different IV and also add this IV block to the final ciphertext, to have the different values as result.

The IV is not a secret, so is safe to be included in the final ciphertext.

The .Net Aes already has a random IV value when is created:

`
using (Aes myAes = Aes.Create())
{

        // Encrypt the string to an array of bytes.
        byte[] encrypted = EncryptStringToBytes_Aes(original, myAes.Key, myAes.IV);

`

If you see, the AES instance when is used with Aes.Create() already create an IV.

A possible solution is to create a new buffer that combines these two values as:

Buffer.BlockCopy(iv, 0, result, 0, iv.Length); Buffer.BlockCopy(encryptedContent, 0, result, iv.Length, encryptedContent.Length);

An also, since probably is using the library, should probably be needed to create a migration plan to encrypt properly the actual data encrypted by the library by projects that used it.

For the decryption, you need to split the hypertext and the IV from the block, and from there, you can use the key, and the unique IV to decrypt the value.

.NET 7, nothing happens

Hi,
i am using .NET 7 and i did exactly what you described in documentation but nothing happens, my data is still saved in clear text.
Am i missing something?

here is my dbcontext:

private readonly IEncryptionProvider _provider;
public AppDbContext()
{
_provider = new GenerateEncryptionProvider("example_encrypt_key");
}
.....
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseEncryption(_provider);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);

    OnModelCreatingPartial(modelBuilder);

    base.OnModelCreating(modelBuilder);
}

and my entity model:
[EncryptColumn]
public string UserName { get; set; }

    [EncryptColumn]
    public string FirstName { get; set; }
    
    public string Email { get; set; }

Decryption does not work

I have tested you example https://github.com/emrekizildas/EntityFrameworkCore.EncryptColumn.Example and the first time it works, the second time I run it I get the following output:

ID: 9c2016b2-bf54-47d0-a9d0-23d94858ecad
Firstname: Emre
Lastname: Kizildas
Email Address: 
Identity Number: 
ID: d2a1252a-c7b3-41c6-b87a-e88ede34144a
Firstname: Emre
Lastname: Kizildas
Email Address: [email protected]
Identity Number: 12345678901

It seems like it can't decrypt objects created by another instance of the DBContext.

5.0.6 data loss bug

The current release writes an empty string to the database instead of the encrypted value. I was able to verify this using the example project, after upgrading that project to EncryptColumn 5.0.6.

Looking at the repository history, it looks like the issue may have been resolved here back in August, but an updated NuGet package wasn't published afterward.

any plans to support .net8?

System.MissingMethodException: 'Method not found: 'System.Collections.Generic.IEnumerable`1<Microsoft.EntityFrameworkCore.Metadata.IMutableProperty> Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType.GetProperties()'.'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.