MS SQL 에서 AES 256 암호키 생성시
삭제는 생성과 반대로
drop SYMMETRIC KEY <symmetrickey_id>
drop CERTIFICATE <certificate_id>
drop MASTER KEY
암호용키생성
IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = <idvalue>)
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'keyvalue....'
GO
인증서 생성
CREATE CERTIFICATE <certificate_id> WITH SUBJECT = 'subject........';
GO
대칭키를 인증서로 암호
CREATE SYMMETRIC KEY <symmetrickey_id> WITH ALGORITHM = AES_256,
KEY_SOURCE = 'ENC_KEY',
IDENTITY_VALUE = 'ENC_VALUE_Key'
ENCRYPTION BY CERTIFICATE <certificate_id>;
GO
키 사용권한 부여
USE databasename;
GRANT CONTROL ON SYMMETRIC KEY::<symmetrickey_id> TO usersqlid;
USE databasename;
GRANT CONTROL ON CERTIFICATE ::<certificate_id> TO usersqlid;
drop SYMMETRIC KEY <symmetrickey_id>
drop CERTIFICATE <certificate_id>
drop MASTER KEY
암호용키생성
IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = <idvalue>)
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'keyvalue....'
GO
인증서 생성
CREATE CERTIFICATE <certificate_id> WITH SUBJECT = 'subject........';
GO
대칭키를 인증서로 암호
CREATE SYMMETRIC KEY <symmetrickey_id> WITH ALGORITHM = AES_256,
KEY_SOURCE = 'ENC_KEY',
IDENTITY_VALUE = 'ENC_VALUE_Key'
ENCRYPTION BY CERTIFICATE <certificate_id>;
GO
키 사용권한 부여
USE databasename;
GRANT CONTROL ON SYMMETRIC KEY::<symmetrickey_id> TO usersqlid;
USE databasename;
GRANT CONTROL ON CERTIFICATE ::<certificate_id> TO usersqlid;
댓글
댓글 쓰기