Showing posts with label properly. Show all posts
Showing posts with label properly. Show all posts

Sunday, March 25, 2012

data encryption

Ideai have to encrypt my data in sql2005 database using assymetric key encryption which i have done properly.But i have a doubt that while writing stored procedure i have to provide key information in it , that will be visible to everyone then whats the use of taht encryption. Can anyone tell me how can i write stored procedure without providing key information in it.

Divya

Well, you can have SQL Server manage the keys for you, then you never have to expose them to client applications.

But I assume from your question that you are using passwords (passphrases) to protect the asymmetric keys? If so, is there a reason you are doing that? You could instead protect the key using the database master key and then not have to worry about providing the key in your stored procedure.

Don

|||

A very good tutorial for similar situation is

http://aspnet.4guysfromrolla.com/articles/022807-1.aspx

|||

It all depends on who and what you are trying to protect from.

By the web server passing the key, the loss of just the physical database server itself would be meaningless. You couldn't decrypt the data on it since they does not exist on that machine. It also can simplify a number of other issues as well since the key is stored with the application that is accessing the data. And it does make for a stronger link between application and data. if you were store the key on the database (and not pass it), then you most likely wouldn't gain very much. The stored procedure could look it up, but then you are subject to the problem that if the physical machine is compomised (Stolen), the data can be decrypted. It also causes a problem because then you have to make a second security layer so that the stored procedure is only then able to be executed by connections it trusts. And if you write that layer, what is the point of a stored procedure that encrypts data since you are now dependant on the security of the connection? If you can trust the connection, the just put permissions on your tables and you've got the same level of security. If somehow the stored procedure is compromised, again, the encryption is useless. It's encrypted, but anyone can decrypt it just by asking, so what is the point in that?

Now, that's not to say that the key being stored/sent from the application doesn't have it's own set of problems, but there is a lot more to encryption and security that must be thought through. And your security scheme must reflect what types of attacks you want to protect yourself from. All-in-all, having the application send the key is more secure in most cases. Just make sure your connection is encrypted as well.

|||

hello don,

i tried d solution suggested by u by creating the database master key, but i am not able to take backup of this key in ntfs directory as it involves editing registry information. Can u suggest me any feasible solution for it.

Thanks

Divya

|||Hello don i tried this solution from this linkhttp://www.sqlservercentral.com/columnists/mcoles/sql2005symmetricencryption.asp and trying to encrypt and decrypt using database master key , creating certificate without password but here i am not able to decrypt the column with this method, can u plz help me on this.|||

Why don't you post the code you're using at this point? That will make it easier to see what you're trying to do.

And is a certificate the best type of encryption to use? Why did you select that? (I don't mean to imply there is anything wrong with that choice. I just want to understand what you are trying to do.)

Don

|||

thanx don, earlier i was trying the encryption using password. But when i tried using master key it worked fine.

thanx

Wednesday, March 7, 2012

data are not allocated in the properly NDF. Why?

Hi everyone,

The followings actions works fine. But only the first NDF (PRIMERO) is growing up.

I don't get the point at all, I though that SEGUNDO would store February, TERCERO March and

CUARTO April to December (according RANGE LEFT)

I feel that there is something very important that I did not in all of this...

I'm stuck.

--Definition table

CREATE TABLE [dbo].[DatosMensuales](

[Id] [int] NOT NULL,

[Concepto] [varchar](50) COLLATE Modern_Spanish_CI_AS NULL,

[FechaAlta] [datetime] NULL

) ON rangoMesFE(FechaAlta)

CREATE PARTITION FUNCTION rangoMesFP(datetime)

AS RANGE LEFT FOR VALUES('200601','200602','200603');

CREATE PARTITION SCHEME rangoMesFE

AS PARTITION rangoMesFP

TO (PRIMERO,SEGUNDO,TERCERO,CUARTO);

--loading data properly

EXEC CARGARMESES '2006-01-01 00:01:01', 'PRUEBAS ENERO', 1, 10000

EXEC CARGARMESES '2006-02-01 00:01:01', 'PRUEBAS FEBRERO', 10001,20000

EXEC CARGARMESES '2006-03-01 00:01:01', 'PRUEBAS MARZO', 20001,30000

EXEC CARGARMESES '2006-04-01 00:01:01', 'PRUEBAS ABRIL', 30001,40000

SELECT $partition.rangoMesFP('200606') --> DATA IN THE FOURTH PARTITION, OK

Does anyone have any idea about this?

When I launch sp_helpdb only NDF which belong to PRIMERO partition are altered:

pruebas 1 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\pruebas.mdf PRIMARY 7168 KB Unlimited 1024 KB data only
pruebas_log 2 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\pruebas_log.ldf NULL 1024 KB 2147483648 KB 10% log only
fich_1 3 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_1.ndf PRIMERO 4096 KB Unlimited 1024 KB data only
fich_2 4 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_2.ndf PRIMERO 4096 KB Unlimited 1024 KB data only
fich_5 5 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_5.ndf CUARTO 3072 KB Unlimited 1024 KB data only
fich_6 6 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_6.ndf QUINTO 3072 KB Unlimited 1024 KB data only
fich_3 7 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_3.ndf SEGUNDO 3072 KB Unlimited 1024 KB data only
fich_4 8 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_4.ndf TERCERO 3072 KB Unlimited 1024 KB data only

|||This issue is already solved.

data are not allocated in the properly NDF. Why?

Hi everyone,

The followings actions works fine. But only the first NDF (PRIMERO) is growing up.

I don't get the point at all, I though that SEGUNDO would store February, TERCERO March and

CUARTO April to December (according RANGE LEFT)

I feel that there is something very important that I did not in all of this...

I'm stuck.

--Definition table

CREATE TABLE [dbo].[DatosMensuales](

[Id] [int] NOT NULL,

[Concepto] [varchar](50) COLLATE Modern_Spanish_CI_AS NULL,

[FechaAlta] [datetime] NULL

) ON rangoMesFE(FechaAlta)

CREATE PARTITION FUNCTION rangoMesFP(datetime)

AS RANGE LEFT FOR VALUES('200601','200602','200603');

CREATE PARTITION SCHEME rangoMesFE

AS PARTITION rangoMesFP

TO (PRIMERO,SEGUNDO,TERCERO,CUARTO);

--loading data properly

EXEC CARGARMESES '2006-01-01 00:01:01', 'PRUEBAS ENERO', 1, 10000

EXEC CARGARMESES '2006-02-01 00:01:01', 'PRUEBAS FEBRERO', 10001,20000

EXEC CARGARMESES '2006-03-01 00:01:01', 'PRUEBAS MARZO', 20001,30000

EXEC CARGARMESES '2006-04-01 00:01:01', 'PRUEBAS ABRIL', 30001,40000

SELECT $partition.rangoMesFP('200606') --> DATA IN THE FOURTH PARTITION, OK

Does anyone have any idea about this?

When I launch sp_helpdb only NDF which belong to PRIMERO partition are altered:

pruebas 1 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\pruebas.mdf PRIMARY 7168 KB Unlimited 1024 KB data only
pruebas_log 2 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\pruebas_log.ldf NULL 1024 KB 2147483648 KB 10% log only
fich_1 3 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_1.ndf PRIMERO 4096 KB Unlimited 1024 KB data only
fich_2 4 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_2.ndf PRIMERO 4096 KB Unlimited 1024 KB data only
fich_5 5 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_5.ndf CUARTO 3072 KB Unlimited 1024 KB data only
fich_6 6 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_6.ndf QUINTO 3072 KB Unlimited 1024 KB data only
fich_3 7 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_3.ndf SEGUNDO 3072 KB Unlimited 1024 KB data only
fich_4 8 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fich_4.ndf TERCERO 3072 KB Unlimited 1024 KB data only

|||This issue is already solved.