Skip to content

Commit 3af2e30

Browse files
authored
Added localization support (#46)
1 parent 690c5ee commit 3af2e30

File tree

135 files changed

+1292
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+1292
-752
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
</p>
44

55
[![Discord](https://discordapp.com/api/guilds/926425949078159420/widget.png)](https://discord.gg/NrTxXpJ2Zj)
6+
[![Crowdin](https://badges.crowdin.net/securefolderfs/localized.svg)](https://crowdin.com/project/securefolderfs)
67

78
SecureFolderFS helps you keep your files private. Safeguard your data with cutting-edge cryptographic algorithms that seamlessly secure your data thanks to our advanced on-fly encryption.
89

SecureFolderFS.AvaloniaUI/App.axaml.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ private void EnsureEarlyApp()
6868

6969
private IServiceProvider ConfigureServices(IModifiableFolder settingsFolder)
7070
{
71-
var serviceCollection = new ServiceCollection();
72-
73-
serviceCollection
71+
var serviceCollection = new ServiceCollection()
7472

7573
// Singleton services
7674
.AddSingleton<ISettingsService, SettingsService>(_ => new SettingsService(settingsFolder))

SecureFolderFS.AvaloniaUI/ServiceImplementation/ApplicationService.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using SecureFolderFS.AvaloniaUI.Helpers;
2-
using SecureFolderFS.Sdk.AppModels;
32
using SecureFolderFS.Sdk.Services;
43
using SecureFolderFS.UI.ServiceImplementation;
54
using System;
@@ -15,11 +14,7 @@ internal sealed class ApplicationService : BaseApplicationService
1514
public override string Platform { get; } = "AvaloniaUI";
1615

1716
/// <inheritdoc/>
18-
public override AppVersion GetAppVersion()
19-
{
20-
var version = Assembly.GetExecutingAssembly().GetName().Version!;
21-
return new(version, Platform);
22-
}
17+
public override Version AppVersion { get; } = Assembly.GetExecutingAssembly().GetName().Version!;
2318

2419
/// <inheritdoc/>
2520
public override Task OpenUriAsync(Uri uri)

SecureFolderFS.AvaloniaUI/WindowViews/MainWindow.axaml.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using FluentAvalonia.UI.Windowing;
77
using SecureFolderFS.Sdk.Services;
88
using System;
9+
using SecureFolderFS.Shared.Extensions;
910

1011
namespace SecureFolderFS.AvaloniaUI.WindowViews
1112
{
@@ -86,7 +87,7 @@ private void PrepareBackgroundForMica()
8687
private async void Window_Closing(object? sender, WindowClosingEventArgs e)
8788
{
8889
var settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
89-
await settingsService.SaveAsync();
90+
await settingsService.TrySaveAsync();
9091
}
9192

9293
public static readonly StyledProperty<bool> IsCustomTitleBarVisibleProperty =

SecureFolderFS.Core.Cryptography/CryptImpl/AesCtrCrypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/AesCtrCrypt.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using SecureFolderFS.Core.Cryptography.Cipher;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Security.Cryptography;
54

6-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
5+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
76
{
87
/// <inheritdoc cref="IAesCtrCrypt"/>
98
public sealed class AesCtrCrypt : IAesCtrCrypt
@@ -49,25 +48,25 @@ public bool Decrypt(ReadOnlySpan<byte> bytes, ReadOnlySpan<byte> key, ReadOnlySp
4948
// The MIT License (MIT)
5049

5150
// Copyright (c) 2020 Hans Wolff
52-
51+
5352
// Permission is hereby granted, free of charge, to any person obtaining a copy
5453
// of this software and associated documentation files (the "Software"), to deal
5554
// in the Software without restriction, including without limitation the rights
5655
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5756
// copies of the Software, and to permit persons to whom the Software is
5857
// furnished to do so, subject to the following conditions:
59-
58+
6059
// The above copyright notice and this permission notice shall be included in
6160
// all copies or substantial portions of the Software.
62-
61+
6362
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6463
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6564
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6665
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6766
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6867
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6968
// THE SOFTWARE.
70-
69+
7170
// Source: https://gist.github.com/hanswolff/8809275
7271

7372
internal sealed class AesCounterMode : SymmetricAlgorithm

SecureFolderFS.Core.Cryptography/CryptImpl/AesGcmCrypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/AesGcmCrypt.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using SecureFolderFS.Core.Cryptography.Cipher;
2-
using System;
1+
using System;
32
using System.Security.Cryptography;
43

5-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
4+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
65
{
76
/// <inheritdoc cref="IAesGcmCrypt"/>
87
public sealed class AesGcmCrypt : IAesGcmCrypt

SecureFolderFS.Core.Cryptography/CryptImpl/AesSivCrypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/AesSivCrypt.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using Miscreant;
2-
using SecureFolderFS.Core.Cryptography.Cipher;
32
using System;
43
using System.Runtime.CompilerServices;
54
using System.Security.Cryptography;
65

7-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
6+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
87
{
98
/// <inheritdoc cref="IAesSivCrypt"/>
109
public sealed class AesSivCrypt : IAesSivCrypt

SecureFolderFS.Core.Cryptography/CryptImpl/Argon2idCrypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/Argon2idCrypt.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using Konscious.Security.Cryptography;
2-
using SecureFolderFS.Core.Cryptography.Cipher;
32
using System;
43

5-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
4+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
65
{
76
/// <inheritdoc cref="IArgon2idCrypt"/>
87
public sealed class Argon2idCrypt : IArgon2idCrypt

SecureFolderFS.Core.Cryptography/CryptImpl/HmacSha256Crypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/HmacSha256Crypt.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using SecureFolderFS.Core.Cryptography.Cipher;
2-
using System;
1+
using System;
32
using System.Security.Cryptography;
43

5-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
4+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
65
{
76
/// <inheritdoc cref="IHmacSha256Crypt"/>
87
public sealed class HmacSha256Crypt : IHmacSha256Crypt
@@ -33,10 +32,10 @@ public void Update(ReadOnlySpan<byte> bytes)
3332
}
3433

3534
/// <inheritdoc/>
36-
public void GetHash(Span<byte> destination)
35+
public int GetHash(Span<byte> destination)
3736
{
3837
ArgumentNullException.ThrowIfNull(_incrementalHash);
39-
_incrementalHash.GetCurrentHash(destination);
38+
return _incrementalHash.GetCurrentHash(destination);
4039
}
4140

4241
/// <inheritdoc/>

SecureFolderFS.Core.Cryptography/CryptImpl/Rfc3394KeyWrap.cs SecureFolderFS.Core.Cryptography/Cipher/Default/Rfc3394KeyWrap.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using SecureFolderFS.Core.Cryptography.Cipher;
2-
using System;
1+
using System;
32

4-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
3+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
54
{
65
/// <inheritdoc cref="IRfc3394KeyWrap"/>
76
public sealed class Rfc3394KeyWrap : IRfc3394KeyWrap

SecureFolderFS.Core.Cryptography/CryptImpl/XChaCha20Poly1305Crypt.cs SecureFolderFS.Core.Cryptography/Cipher/Default/XChaCha20Poly1305Crypt.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using NSec.Cryptography;
2-
using SecureFolderFS.Core.Cryptography.Cipher;
32
using System;
43

5-
namespace SecureFolderFS.Core.Cryptography.CryptImpl
4+
namespace SecureFolderFS.Core.Cryptography.Cipher.Default
65
{
76
/// <inheritdoc cref="IXChaCha20Poly1305Crypt"/>
87
public sealed class XChaCha20Poly1305Crypt : IXChaCha20Poly1305Crypt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Security.Cryptography;
3+
4+
namespace SecureFolderFS.Core.Cryptography.Cipher
5+
{
6+
/// <summary>
7+
/// Defines the basic operations of cryptographic transformations using <see cref="Span{T}"/> and <see cref="ReadOnlySpan{T}"/>.
8+
/// </summary>
9+
public interface ICryptoTransformSpan : ICryptoTransform
10+
{
11+
/// <summary>
12+
/// Transforms the specified region of the input <see cref="ReadOnlySpan{T}"/> and copies the resulting transform to the output <see cref="Span{T}"/>.
13+
/// </summary>
14+
/// <remarks>
15+
/// The return value of <see cref="TransformBlock"/> is the number of bytes returned to <paramref name="outputBuffer"/> and is always less than or equal
16+
/// to <see cref="ICryptoTransform.OutputBlockSize"/>. If <see cref="ICryptoTransform.CanTransformMultipleBlocks"/> is true, then the size of <paramref name="inputBuffer"/>
17+
/// must be any positive multiple of <see cref="ICryptoTransform.InputBlockSize"/>.
18+
/// </remarks>
19+
/// <param name="inputBuffer">The input for which to compute the transform.</param>
20+
/// <param name="outputBuffer">The output to which to write the transform.</param>
21+
/// <returns>The number of bytes written.</returns>
22+
int TransformBlock(ReadOnlySpan<byte> inputBuffer, Span<byte> outputBuffer);
23+
24+
/// <summary>
25+
/// Transforms the specified region of the specified byte array.
26+
/// </summary>
27+
/// <remarks>
28+
/// <see cref="TransformFinalBlock"/> is a special function for transforming the last block or a partial block in the stream.
29+
/// </remarks>
30+
/// <param name="inputBuffer">The input for which to compute the transform.</param>
31+
/// <param name="outputBuffer">The output to which to write the computed transform.</param>
32+
/// <returns>The number of bytes written.</returns>
33+
int TransformFinalBlock(ReadOnlySpan<byte> inputBuffer, Span<byte> outputBuffer);
34+
35+
/// <summary>
36+
/// Calculates the transform length for the output of <see cref="TransformFinalBlock"/>.
37+
/// </summary>
38+
/// <param name="inputLength">The number of bytes used for input for which the transform length is calculated.</param>
39+
/// <returns>The number of bytes used for the final transform.</returns>
40+
int CalculateFinalTransform(int inputLength);
41+
}
42+
}

SecureFolderFS.Core.Cryptography/Cipher/IHmacSha256Crypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface IHmacSha256Instance : IDisposable
1515

1616
void Update(ReadOnlySpan<byte> bytes);
1717

18-
void GetHash(Span<byte> destination);
18+
int GetHash(Span<byte> destination);
1919
}
2020
}

SecureFolderFS.Core.Cryptography/CipherProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using SecureFolderFS.Core.Cryptography.Cipher;
2-
using SecureFolderFS.Core.Cryptography.CryptImpl;
2+
using SecureFolderFS.Core.Cryptography.Cipher.Default;
33
using System;
44

55
namespace SecureFolderFS.Core.Cryptography

SecureFolderFS.Core.Cryptography/ContentCrypt/AesCtrHmacContentCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace SecureFolderFS.Core.Cryptography.ContentCrypt
99
{
1010
/// <inheritdoc cref="IContentCrypt"/>
11-
public sealed class AesCtrHmacContentCrypt : BaseContentCrypt
11+
internal sealed class AesCtrHmacContentCrypt : BaseContentCrypt
1212
{
1313
private readonly SecretKey _macKey;
1414

SecureFolderFS.Core.Cryptography/ContentCrypt/BaseContentCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace SecureFolderFS.Core.Cryptography.ContentCrypt
55
{
66
/// <inheritdoc cref="IContentCrypt"/>
7-
public abstract class BaseContentCrypt : IContentCrypt
7+
internal abstract class BaseContentCrypt : IContentCrypt
88
{
99
protected readonly CipherProvider cipherProvider;
1010
protected readonly RandomNumberGenerator secureRandom;

SecureFolderFS.Core.Cryptography/ContentCrypt/XChaChaContentCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace SecureFolderFS.Core.Cryptography.ContentCrypt
1010
{
1111
/// <inheritdoc cref="IContentCrypt"/>
12-
public sealed class XChaChaContentCrypt : BaseContentCrypt
12+
internal sealed class XChaChaContentCrypt : BaseContentCrypt
1313
{
1414
/// <inheritdoc/>
1515
public override int ChunkCleartextSize { get; } = CHUNK_CLEARTEXT_SIZE;

SecureFolderFS.Core.Cryptography/HeaderCrypt/AesCtrHmacHeaderCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace SecureFolderFS.Core.Cryptography.HeaderCrypt
88
{
99
/// <inheritdoc cref="IHeaderCrypt"/>
10-
public sealed class AesCtrHmacHeaderCrypt : BaseHeaderCrypt
10+
internal sealed class AesCtrHmacHeaderCrypt : BaseHeaderCrypt
1111
{
1212
/// <inheritdoc/>
1313
public override int HeaderCiphertextSize { get; } = HEADER_SIZE;

SecureFolderFS.Core.Cryptography/HeaderCrypt/AesGcmHeaderCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace SecureFolderFS.Core.Cryptography.HeaderCrypt
77
{
88
/// <inheritdoc cref="IHeaderCrypt"/>
9-
public sealed class AesGcmHeaderCrypt : BaseHeaderCrypt
9+
internal sealed class AesGcmHeaderCrypt : BaseHeaderCrypt
1010
{
1111
/// <inheritdoc/>
1212
public override int HeaderCiphertextSize { get; } = HEADER_SIZE;

SecureFolderFS.Core.Cryptography/HeaderCrypt/BaseHeaderCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace SecureFolderFS.Core.Cryptography.HeaderCrypt
66
{
77
/// <inheritdoc cref="IHeaderCrypt"/>
8-
public abstract class BaseHeaderCrypt : IHeaderCrypt
8+
internal abstract class BaseHeaderCrypt : IHeaderCrypt
99
{
1010
protected readonly SecretKey encKey;
1111
protected readonly SecretKey macKey;

SecureFolderFS.Core.Cryptography/HeaderCrypt/XChaChaHeaderCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace SecureFolderFS.Core.Cryptography.HeaderCrypt
77
{
88
/// <inheritdoc cref="IHeaderCrypt"/>
9-
public sealed class XChaChaHeaderCrypt : BaseHeaderCrypt
9+
internal sealed class XChaChaHeaderCrypt : BaseHeaderCrypt
1010
{
1111
/// <inheritdoc/>
1212
public override int HeaderCiphertextSize { get; } = HEADER_SIZE;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Security.Cryptography;
3+
4+
namespace SecureFolderFS.Core.Cryptography
5+
{
6+
internal interface ISecurity
7+
{
8+
IFormatProvider NameCryptFormatProvider { get; }
9+
10+
ICryptoTransform CreateEncryptor();
11+
12+
ICryptoTransform CreateDecryptor();
13+
}
14+
}

SecureFolderFS.Core.Cryptography/NameCrypt/BaseNameCrypt.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public virtual string EncryptName(ReadOnlySpan<char> cleartextName, ReadOnlySpan
2626
{
2727
// Allocate byte* for encoding
2828
var length = Encoding.UTF8.GetByteCount(cleartextName);
29-
var bytes = length < 255 ? stackalloc byte[length] : new byte[length];
29+
var bytes = length < 256 ? stackalloc byte[length] : new byte[length];
3030

3131
// Get bytes from cleartext name
3232
var count = Encoding.UTF8.GetBytes(cleartextName, bytes);

SecureFolderFS.Core.Cryptography/NameCrypt/INameCrypt.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public interface INameCrypt
1111
/// Encrypts the <paramref name="cleartextName"/> using associated <paramref name="directoryId"/>.
1212
/// </summary>
1313
/// <param name="cleartextName">The cleartext name to encrypt.</param>
14-
/// <param name="directoryId">The associated directory ID.</param>
14+
/// <param name="directoryId">The associated DirectoryID.</param>
1515
/// <returns>Encrypted ciphertext name.</returns>
1616
string EncryptName(ReadOnlySpan<char> cleartextName, ReadOnlySpan<byte> directoryId);
1717

1818
/// <summary>
1919
/// Decrypts the <paramref name="ciphertextName"/> using associated <paramref name="directoryId"/>.
2020
/// </summary>
2121
/// <param name="ciphertextName">The ciphertext name to encrypt.</param>
22-
/// <param name="directoryId">The associated directory ID.</param>
22+
/// <param name="directoryId">The associated DirectoryID.</param>
2323
/// <returns>If the name was successfully decrypted, returns cleartext name, otherwise null.</returns>
2424
string? DecryptName(ReadOnlySpan<char> ciphertextName, ReadOnlySpan<byte> directoryId);
2525
}

SecureFolderFS.Core.Cryptography/SecureFolderFS.Core.Cryptography.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19+
<ProjectReference Include="..\SecureFolderFS.Core.FileSystem\SecureFolderFS.Core.FileSystem.csproj" />
20+
<ProjectReference Include="..\SecureFolderFS.Sdk.Storage\SecureFolderFS.Sdk.Storage.csproj" />
1921
<ProjectReference Include="..\SecureFolderFS.Shared\SecureFolderFS.Shared.csproj" />
2022
</ItemGroup>
2123

0 commit comments

Comments
 (0)