Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcfanning committed Feb 24, 2025
1 parent 9ce5e2d commit 54c410a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
16 changes: 8 additions & 8 deletions src/Cask/Cask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ private static void FinalizeKey(Span<byte> key,
ValidateTimestamp(now);
ReadOnlySpan<char> chars = [
Base64UrlChars[now.Year - 2024], // Years since 2024.
Base64UrlChars[now.Month - 1], // Zero-indexed month.
Base64UrlChars[now.Day - 1], // Zero-indexed day.
Base64UrlChars[now.Hour], // Zero-indexed hour.
];
Base64UrlChars[now.Month - 1], // Zero-indexed month.
Base64UrlChars[now.Day - 1], // Zero-indexed day.
Base64UrlChars[now.Hour], // Zero-indexed hour.
];

bytesWritten = Base64Url.DecodeFromChars(chars, key[YearMonthHoursDaysTimestampByteRange]);
Debug.Assert(bytesWritten == 3);
Expand All @@ -207,10 +207,10 @@ private static void FinalizeKey(Span<byte> key,

chars = [
Base64UrlChars[now.Minute], // Zero-indexed minute.
expiryChars[0],
expiryChars[1],
expiryChars[2],
];
expiryChars[0],
expiryChars[1],
expiryChars[2],
];

bytesWritten = Base64Url.DecodeFromChars(chars, key[MinutesAndExpiryByteRange]);
Debug.Assert(bytesWritten == 3);
Expand Down
9 changes: 0 additions & 9 deletions src/Cask/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ public static int GetKeyLengthInBytes(int providerDataLengthInBytes)
return keyLengthInBytes;
}

public static int GetHashLengthInBytes(int secretSizeInBytes)
{
int hashLengthInBytes = PaddedHmacSha256SizeInBytes + secretSizeInBytes;
Debug.Assert(Is3ByteAligned(secretSizeInBytes));
Debug.Assert(Is3ByteAligned(hashLengthInBytes));
return hashLengthInBytes;
}


public static SensitiveDataSize CharToSensitiveDataSize(char sensitiveDataSizeChar)
{
return (SensitiveDataSize)(sensitiveDataSizeChar - 'A'); ;
Expand Down
10 changes: 5 additions & 5 deletions src/Cask/Limits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public static class Limits
public static int MaxProviderDataLengthInChars { get; } = BytesToBase64Chars(MaxProviderDataLengthInBytes);

/// <summary>
/// The minimum length of a Cask key or hash when decoded to bytes.
/// The minimum length of a Cask secret when decoded to bytes.
/// </summary>
public static int MinKeyLengthInBytes { get; } = GetKeyLengthInBytes(0);

/// <summary>
/// The maximum length of a Cask key or hash when decoded to bytes.
/// The maximum length of a Cask secret when decoded to bytes.
/// </summary>
public static int MaxKeyLengthInBytes { get; } = GetHashLengthInBytes(GetKeyLengthInBytes(MaxProviderDataLengthInBytes) - 33);
public static int MaxKeyLengthInBytes { get; } = GetKeyLengthInBytes(MaxProviderDataLengthInBytes);

/// <summary>
/// The minimum length of a Cask key in characters.
/// The minimum length of a Cask secret in characters.
/// </summary>
public static int MinKeyLengthInChars { get; } = BytesToBase64Chars(MinKeyLengthInBytes);

/// <summary>
/// The maximum length of a Cask key in characters.
/// The maximum length of a Cask secret in characters.
/// </summary>
public static int MaxKeyLengthInChars { get; } = BytesToBase64Chars(MaxKeyLengthInBytes);

Expand Down

0 comments on commit 54c410a

Please sign in to comment.