mirror of
https://github.com/bitwarden/server.git
synced 2025-06-20 02:48:03 -05:00
Apply fixes
This commit is contained in:
parent
76e9be5ef6
commit
f15dcdba5e
@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using Bit.Core.KeyManagement.Enums;
|
||||
using Bit.Core.KeyManagement.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
@ -7,14 +6,22 @@ namespace Bit.Api.KeyManagement.Models.Requests;
|
||||
|
||||
public class SignatureKeyPairRequestModel
|
||||
{
|
||||
public required SignatureAlgorithm SignatureAlgorithm { get; set; }
|
||||
public required string SignatureAlgorithm { get; set; }
|
||||
[EncryptedString] public required string WrappedSigningKey { get; set; }
|
||||
public required string VerifyingKey { get; set; }
|
||||
|
||||
public SignatureKeyPairData ToSignatureKeyPairData()
|
||||
{
|
||||
if (SignatureAlgorithm != "ed25519")
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Unsupported signature algorithm: {SignatureAlgorithm}"
|
||||
);
|
||||
}
|
||||
var algorithm = Core.KeyManagement.Enums.SignatureAlgorithm.Ed25519;
|
||||
|
||||
return new SignatureKeyPairData(
|
||||
SignatureAlgorithm,
|
||||
algorithm,
|
||||
WrappedSigningKey,
|
||||
VerifyingKey
|
||||
);
|
||||
|
@ -8,8 +8,8 @@ namespace Bit.Api.KeyManagement.Models.Response;
|
||||
|
||||
public class SignatureKeyPairResponseModel : ResponseModel
|
||||
{
|
||||
public required string WrappedSigningKey;
|
||||
public required string VerifyingKey;
|
||||
public required string WrappedSigningKey { get; set; }
|
||||
public required string VerifyingKey { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute]
|
||||
public SignatureKeyPairResponseModel(SignatureKeyPairData signatureKeyPair)
|
||||
|
@ -28,13 +28,13 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
return await connection.QuerySingleOrDefaultAsync<SignatureKeyPairData>(
|
||||
return (await connection.QuerySingleOrDefaultAsync<UserSignatureKeyPair>(
|
||||
"[dbo].[UserSignatureKeyPair_ReadByUserId]",
|
||||
new
|
||||
{
|
||||
UserId = userId
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
commandType: CommandType.StoredProcedure))?.ToSignatureKeyPairData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb(),
|
||||
UserId = userId,
|
||||
SignatureAlgorithm = (byte)signingKeys.SignatureAlgorithm,
|
||||
SignatureKeyPairAlgorithm = (byte)signingKeys.SignatureAlgorithm,
|
||||
SigningKey = signingKeys.WrappedSigningKey,
|
||||
signingKeys.VerifyingKey,
|
||||
CreationDate = DateTime.UtcNow,
|
||||
|
Loading…
x
Reference in New Issue
Block a user