From a2977541e02592c15f4b26a4ee3c1c41139c7db1 Mon Sep 17 00:00:00 2001 From: TheThing <jonatan@nilsson.is> Date: Sun, 9 Feb 2025 06:51:15 +0000 Subject: [PATCH] Update readme with installation instructions --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dbc45c3..267ca20 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,73 @@ -# sql_hashers +# SQL Hashers -MS SQL CLR implementation of Argon2id hasher for secure password hashing in database \ No newline at end of file +A collection of new and secure hashing algorithms for Microsoft SQL Servers using CLR to bring Microsoft SQL into the 21st century. + +# Features + + +### Hashing Algorithms: + +* **Argon2id** (with salt and verification) + +# Installation + +Build yourself or grab the combined dll from releases. +Copy it to a path on the server with a running MS SQL. + +Run following SQL Script: + +```sql +DROP PROCEDURE IF EXISTS argon2id_hash; +GO + +DROP PROCEDURE IF EXISTS argon2id_hash_custom; +GO + +DROP PROCEDURE IF EXISTS argon2id_verify; +GO + +DROP ASSEMBLY IF EXISTS clr_hashers; +GO + +ALTER DATABASE [your_database_name_here] SET TRUSTWORTHY ON; +go + +CREATE ASSEMBLY clr_hashers from 'C:\clr\MsSQL2019_hashers.dll' WITH PERMISSION_SET = unsafe; +GO + +-- Taken from https://sqlquantumleap.com/2017/09/29/sqlclr-vs-sql-server-2017-part-6-trusted-assemblies-cant-do-module-signing/ +DECLARE @Hash BINARY(64), + @ClrName NVARCHAR(4000), + @AssemblySize INT, + @MvID UNIQUEIDENTIFIER; + +SELECT @Hash = HASHBYTES(N'SHA2_512', af.[content]), + @ClrName = CONVERT(NVARCHAR(4000), ASSEMBLYPROPERTY(af.[name], + N'CLRName')), + @AssemblySize = DATALENGTH(af.[content]), + @MvID = CONVERT(UNIQUEIDENTIFIER, ASSEMBLYPROPERTY(af.[name], N'MvID')) +FROM sys.assembly_files af + JOIN sys.assemblies a ON (af.assembly_id = a.assembly_id) +WHERE a.name = 'clr_hashers' +AND af.[file_id] = 1; + +SELECT @ClrName, @AssemblySize, @MvID, @Hash; + +EXEC sys.sp_add_trusted_assembly @Hash, @ClrName; +GO + +ALTER DATABASE [your_database_name_here] SET TRUSTWORTHY OFF; +go + +CREATE PROCEDURE argon2id_hash(@password NVARCHAR (256), @hash NVARCHAR (256) OUTPUT) + AS EXTERNAL NAME clr_hashers.SqlHashers.Argon2id_hash; +GO + +CREATE PROCEDURE argon2id_hash_custom(@password NVARCHAR (256), @parallel SMALLINT, @memory SMALLINT, @iterations SMALLINT, @bc SMALLINT, @output NVARCHAR (256) OUTPUT) + AS EXTERNAL NAME clr_hashers.SqlHashers.Argon2id_hash_custom; +GO + +CREATE PROCEDURE argon2id_verify(@i NVARCHAR (256), @h NVARCHAR (256)) + AS EXTERNAL NAME clr_hashers.SqlHashers.Argon2id_verify; +GO +``` \ No newline at end of file