Skip to content

Commit

Permalink
apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-mh committed Aug 26, 2023
1 parent a567261 commit 0738f74
Show file tree
Hide file tree
Showing 299 changed files with 2,423 additions and 2,305 deletions.
22 changes: 11 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ insert_final_newline = false

# Organize usings
dotnet_separate_import_directive_groups = false
file_header_template = Copyright (C) 2023 jmh\nSPDX-License-Identifier: GPL-3.0-only
file_header_template = Copyright (C) 2023 jmh\nSPDX-License-Identifier:GPL-3.0-only

# this. and Me. preferences
dotnet_style_qualification_for_event = false:suggestion
Expand Down Expand Up @@ -184,26 +184,26 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

# Microsoft .NET properties
Expand Down Expand Up @@ -245,9 +245,9 @@ dotnet_naming_symbols.method_symbols.applicable_kinds = method
dotnet_naming_symbols.property_symbols.applicable_accessibilities = *
dotnet_naming_symbols.property_symbols.applicable_kinds = property
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_accessibilities = *
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace,class,struct,enum,delegate
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace, class, struct, enum, delegate
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance

Expand Down
36 changes: 18 additions & 18 deletions AuthenticatorPro.Core/AuthenticatorPro.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="protobuf-net" Version="3.2.26" />
<PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="SimpleBase" Version="4.0.0" />
<PackageReference Include="sqlite-net-sqlcipher" Version="1.8.116" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0"/>
<PackageReference Include="protobuf-net" Version="3.2.26"/>
<PackageReference Include="QRCoder" Version="1.4.3"/>
<PackageReference Include="SharpZipLib" Version="1.4.2"/>
<PackageReference Include="SimpleBase" Version="4.0.0"/>
<PackageReference Include="sqlite-net-sqlcipher" Version="1.8.116"/>
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions AuthenticatorPro.Core/src/AuthenticatorType.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Generator;
using System;
using AuthenticatorPro.Core.Generator;

namespace AuthenticatorPro.Core
{
public enum AuthenticatorType
{
Hotp = 1, Totp = 2, MobileOtp = 3, SteamOtp = 4, YandexOtp = 5
Hotp = 1,
Totp = 2,
MobileOtp = 3,
SteamOtp = 4,
YandexOtp = 5
}

public static class AuthenticatorTypeSpecification
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorPro.Core/src/Backup/Backup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System.Collections.Generic;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Backup
{
Expand Down
6 changes: 3 additions & 3 deletions AuthenticatorPro.Core/src/Backup/ConversionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace AuthenticatorPro.Core.Backup
{
public class ConversionResult
{
public Backup Backup { get; set; }
public List<ConversionFailure> Failures { get; set; }

public ConversionResult()
{
Failures = new List<ConversionFailure>();
}

public Backup Backup { get; set; }
public List<ConversionFailure> Failures { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (C) 2023 jmh
// SPDX-License-Identifier: GPL-3.0-only

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuthenticatorPro.Core.Backup.Encryption
{
Expand All @@ -31,17 +31,6 @@ public class LegacyBackupEncryption : IBackupEncryption
private const string AlgorithmDescription = BaseAlgorithm + "/" + Mode + "/" + Padding;
private const int IvLength = 16;

private static Task<KeyParameter> DeriveKeyAsync(string password, byte[] salt)
{
return Task.Run(delegate
{
var passwordBytes = Encoding.UTF8.GetBytes(password);
var generator = new Pkcs5S2ParametersGenerator(new Sha1Digest());
generator.Init(passwordBytes, salt, Iterations);
return (KeyParameter) generator.GenerateDerivedParameters(BaseAlgorithm, KeyLength * 8);
});
}

public async Task<byte[]> EncryptAsync(Backup backup, string password)
{
if (string.IsNullOrEmpty(password))
Expand Down Expand Up @@ -69,7 +58,8 @@ public async Task<byte[]> EncryptAsync(Backup backup, string password)
Buffer.BlockCopy(headerBytes, 0, output, 0, headerBytes.Length);
Buffer.BlockCopy(salt, 0, output, headerBytes.Length, SaltLength);
Buffer.BlockCopy(iv, 0, output, headerBytes.Length + SaltLength, IvLength);
Buffer.BlockCopy(encryptedData, 0, output, headerBytes.Length + SaltLength + IvLength, encryptedData.Length);
Buffer.BlockCopy(encryptedData, 0, output, headerBytes.Length + SaltLength + IvLength,
encryptedData.Length);

return output;
}
Expand Down Expand Up @@ -122,5 +112,16 @@ public bool CanBeDecrypted(byte[] data)
var headerBytes = Encoding.UTF8.GetBytes(Header);
return headerBytes.SequenceEqual(foundHeader);
}

private static Task<KeyParameter> DeriveKeyAsync(string password, byte[] salt)
{
return Task.Run(delegate
{
var passwordBytes = Encoding.UTF8.GetBytes(password);
var generator = new Pkcs5S2ParametersGenerator(new Sha1Digest());
generator.Init(passwordBytes, salt, Iterations);
return (KeyParameter) generator.GenerateDerivedParameters(BaseAlgorithm, KeyLength * 8);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2023 jmh
// SPDX-License-Identifier: GPL-3.0-only

using Newtonsoft.Json;
using System;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace AuthenticatorPro.Core.Backup.Encryption
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (C) 2023 jmh
// SPDX-License-Identifier: GPL-3.0-only

using Konscious.Security.Cryptography;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Konscious.Security.Cryptography;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;

namespace AuthenticatorPro.Core.Backup.Encryption
{
Expand All @@ -34,19 +34,6 @@ public class StrongBackupEncryption : IBackupEncryption
private const int IvLength = 12;
private const int TagLength = 16;

private static async Task<byte[]> DeriveKeyAsync(string password, byte[] salt)
{
var passwordBytes = Encoding.UTF8.GetBytes(password);

var argon2 = new Argon2id(passwordBytes);
argon2.DegreeOfParallelism = Parallelism;
argon2.Iterations = Iterations;
argon2.MemorySize = MemorySize;
argon2.Salt = salt;

return await argon2.GetBytesAsync(KeyLength);
}

public async Task<byte[]> EncryptAsync(Backup backup, string password)
{
if (string.IsNullOrEmpty(password))
Expand Down Expand Up @@ -74,7 +61,8 @@ public async Task<byte[]> EncryptAsync(Backup backup, string password)
Buffer.BlockCopy(headerBytes, 0, output, 0, headerBytes.Length);
Buffer.BlockCopy(salt, 0, output, headerBytes.Length, SaltLength);
Buffer.BlockCopy(iv, 0, output, headerBytes.Length + SaltLength, IvLength);
Buffer.BlockCopy(encryptedData, 0, output, headerBytes.Length + SaltLength + IvLength, encryptedData.Length);
Buffer.BlockCopy(encryptedData, 0, output, headerBytes.Length + SaltLength + IvLength,
encryptedData.Length);

return output;
}
Expand Down Expand Up @@ -127,5 +115,18 @@ public bool CanBeDecrypted(byte[] data)
var headerBytes = Encoding.UTF8.GetBytes(Header);
return headerBytes.SequenceEqual(foundHeader);
}

private static async Task<byte[]> DeriveKeyAsync(string password, byte[] salt)
{
var passwordBytes = Encoding.UTF8.GetBytes(password);

var argon2 = new Argon2id(passwordBytes);
argon2.DegreeOfParallelism = Parallelism;
argon2.Iterations = Iterations;
argon2.MemorySize = MemorySize;
argon2.Salt = salt;

return await argon2.GetBytesAsync(KeyLength);
}
}
}
4 changes: 2 additions & 2 deletions AuthenticatorPro.Core/src/Backup/HtmlBackup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using QRCoder;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using AuthenticatorPro.Core.Entity;
using QRCoder;

namespace AuthenticatorPro.Core.Backup
{
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorPro.Core/src/Backup/UriListBackup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System;
using System.Collections.Generic;
using System.Text;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Backup
{
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorPro.Core/src/ByteArrayConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: GPL-3.0-only

#nullable enable
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;

namespace AuthenticatorPro.Core
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System;
using System.Collections.Generic;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Comparer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System;
using System.Collections.Generic;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Comparer
{
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorPro.Core/src/Comparer/CategoryComparer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System;
using System.Collections.Generic;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Comparer
{
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorPro.Core/src/Comparer/CustomIconComparer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2022 jmh
// SPDX-License-Identifier: GPL-3.0-only

using AuthenticatorPro.Core.Entity;
using System;
using System.Collections.Generic;
using AuthenticatorPro.Core.Entity;

namespace AuthenticatorPro.Core.Comparer
{
Expand Down
Loading

0 comments on commit 0738f74

Please sign in to comment.