Skip to content

Commit

Permalink
Merge branch 'v4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasilina Bezuglaya authored and Vasilina Bezuglaya committed May 5, 2017
2 parents 8013de2 + 9b94437 commit d4a9e5a
Show file tree
Hide file tree
Showing 46 changed files with 3,986 additions and 121 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,6 @@ Nuget/output
# MacOS
# ==========================

*.DS_Store
*.DS_Store
/docs/
myresults.xml
2 changes: 1 addition & 1 deletion Nuget/msbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, msbuild=None, mstest=None, nuget=None, trx2html=None):

# Path to nuget packager
if nuget==None:
self.nuget = r'nuget'
self.nuget = r'./CryptoLib/NuGet.exe'
else:
self.nuget = nuget

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Virgil Security .NET/C# SDK
[![Build status](https://ci.appveyor.com/api/projects/status/kqs4lqw426gbpccm/branch/release?svg=true)](https://ci.appveyor.com/project/unlim-it/virgil-sdk-net/branch/release) [![Nuget package](https://img.shields.io/nuget/v/Virgil.SDK.svg)](https://www.nuget.org/packages/Virgil.SDK/)

[Installation](#installation) | [Encryption Example](#encryption-example) | [Initialization](#initialization) | [Documentation](#documentation) | [Support](#support)
[Installation](#installation) | [Encryption Example](#encryption-example) | [Initialization](#initialization) | [Documentation](#documentation) | [Reference API][_reference_api] | [Support](#support)

[Virgil Security](https://virgilsecurity.com) provides a set of APIs for adding security to any application. In a few simple steps you can encrypt communication, securely store data, provide passwordless login, and ensure data integrity.

Expand Down Expand Up @@ -95,6 +95,7 @@ Virgil Security has a powerful set of APIs, and the documentation is there to ge
* [Guides][_guides]
* [Virgil Cards][_guide_virgil_cards]
* [Virgil Keys][_guide_virgil_keys]
* [Reference API][_reference_api]

## License

Expand All @@ -117,3 +118,4 @@ Our developer support team is here to help you. You can find us on [Twitter](htt
[_guide_virgil_keys]: https://developer.virgilsecurity.com/docs/cs/guides/virgil-key/generating
[_guide_encryption]: https://developer.virgilsecurity.com/docs/cs/guides/encryption/encrypting
[_initialize_root]: https://developer.virgilsecurity.com/docs/cs/guides/settings/initialize-sdk-on-client
[_reference_api]: http://virgilsecurity.github.io/virgil-sdk-net/
2 changes: 1 addition & 1 deletion SDK/Source/Virgil.SDK.Contracts/Cryptography/Crypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected internal Crypto()
public abstract byte[] Decrypt(byte[] cipherData, IPrivateKey privateKey);
public abstract void Decrypt(Stream inputStream, Stream outputStream, IPrivateKey privateKey);
public abstract byte[] SignThenEncrypt(byte[] data, IPrivateKey privateKey, params IPublicKey[] recipients);
public abstract byte[] DecryptThenVerify(byte[] cipherData, IPrivateKey privateKey, IPublicKey publicKey);
public abstract byte[] DecryptThenVerify(byte[] cipherData, IPrivateKey privateKey, params IPublicKey[] recipients);
public abstract bool Verify(byte[] data, byte[] signature, IPublicKey signerKey);
public abstract bool Verify(Stream inputStream, byte[] signature, IPublicKey signerKey);
public abstract byte[] Sign(byte[] data, IPrivateKey privateKey);
Expand Down
2 changes: 1 addition & 1 deletion SDK/Source/Virgil.SDK.Contracts/Cryptography/ICrypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public interface ICrypto
byte[] ComputeHash(byte[] data, HashAlgorithm algorithm);
byte[] Decrypt(byte[] cipherData, IPrivateKey privateKey);
void Decrypt(Stream inputStream, Stream outputStream, IPrivateKey privateKey);
byte[] DecryptThenVerify(byte[] cipherData, IPrivateKey privateKey, IPublicKey publicKey);
byte[] DecryptThenVerify(byte[] cipherData, IPrivateKey privateKey, params IPublicKey[] recipients);
byte[] Encrypt(byte[] data, params IPublicKey[] recipients);
void Encrypt(Stream inputStream, Stream outputStream, params IPublicKey[] recipients);
byte[] ExportPrivateKey(IPrivateKey privateKey, string password = null);
Expand Down
4 changes: 2 additions & 2 deletions SDK/Source/Virgil.SDK.Contracts/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.2.0")]
20 changes: 10 additions & 10 deletions SDK/Source/Virgil.SDK.Droid/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions SDK/Source/Virgil.SDK.Droid/Virgil.SDK.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidTlsProvider></AndroidTlsProvider>
<AndroidTlsProvider>
</AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -40,42 +41,26 @@
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="Virgil.Crypto, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Virgil.Crypto.2.0.0\lib\monoandroid\Virgil.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\AboutResources.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Values\Strings.xml" />
</ItemGroup>
<Import Project="..\Virgil.SDK.Shared\Virgil.SDK.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\packages\Virgil.Crypto.2.0.0\build\monoandroid\Virgil.Crypto.targets" Condition="Exists('..\packages\Virgil.Crypto.2.0.0\build\monoandroid\Virgil.Crypto.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Virgil.Crypto.2.0.0\build\monoandroid\Virgil.Crypto.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Virgil.Crypto.2.0.0\build\monoandroid\Virgil.Crypto.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
5 changes: 0 additions & 5 deletions SDK/Source/Virgil.SDK.Droid/packages.config

This file was deleted.

4 changes: 2 additions & 2 deletions SDK/Source/Virgil.SDK.NetFx/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.3.0")]
[assembly: AssemblyFileVersion("4.2.3.0")]
[assembly: AssemblyVersion("4.3.0.0")]
[assembly: AssemblyFileVersion("4.3.0.0")]
12 changes: 6 additions & 6 deletions SDK/Source/Virgil.SDK.NetFx/Virgil.SDK.NetFx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Virgil.Crypto, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Virgil.Crypto.2.0.4\lib\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.dll</HintPath>
<Reference Include="Virgil.Crypto, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Virgil.Crypto.2.1.2\lib\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Virgil.SDK.Contracts, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Virgil.SDK.Contracts.1.1.0\lib\portable45-net45+win8+wp8+wpa81\Virgil.SDK.Contracts.dll</HintPath>
<Reference Include="Virgil.SDK.Contracts, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Virgil.SDK.Contracts.1.1.2.0\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Virgil.SDK.Contracts.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand All @@ -68,12 +68,12 @@
<ItemGroup />
<Import Project="..\Virgil.SDK.Shared\Virgil.SDK.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Virgil.Crypto.2.0.4\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets" Condition="Exists('..\packages\Virgil.Crypto.2.0.4\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets')" />
<Import Project="..\packages\Virgil.Crypto.2.1.2\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets" Condition="Exists('..\packages\Virgil.Crypto.2.1.2\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Virgil.Crypto.2.0.4\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Virgil.Crypto.2.0.4\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets'))" />
<Error Condition="!Exists('..\packages\Virgil.Crypto.2.1.2\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Virgil.Crypto.2.1.2\build\portable-net4+sl4+wp7+win8+wpa81\Virgil.Crypto.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 2 additions & 2 deletions SDK/Source/Virgil.SDK.NetFx/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="Virgil.Crypto" version="2.0.4" targetFramework="net45" />
<package id="Virgil.SDK.Contracts" version="1.1.0" targetFramework="net45" />
<package id="Virgil.Crypto" version="2.1.2" targetFramework="net45" />
<package id="Virgil.SDK.Contracts" version="1.1.2.0" targetFramework="net45" />
</packages>
22 changes: 20 additions & 2 deletions SDK/Source/Virgil.SDK.Shared/CardsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace Virgil.SDK
{
using Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -67,7 +68,8 @@ public CardsManager(VirgilApiContext context)
/// <param name="identityType">Type of the identity.</param>
/// <param name="ownerKey">The owner's <see cref="VirgilKey"/>.</param>
/// <param name="customFields">The custom fields (optional).</param>
/// <returns>A new instance of <see cref="VirgilCard"/> class, that is representing user's Public key.</returns>
/// <returns>A new instance of <see cref="VirgilCard"/> class, that is unpublished and
/// representing user's Public key.</returns>
public VirgilCard Create(string identity, VirgilKey ownerKey,
string identityType = "unknown",
Dictionary<string, string> customFields = null)
Expand Down Expand Up @@ -219,19 +221,30 @@ public Task PublishAsync(VirgilCard card)
/// <param name="card">The card to be revoked.</param>
public async Task RevokeAsync(VirgilCard card)
{
if ((this.context == null) || (this.context.Credentials == null) ||
(this.context.Credentials.GetAppId() == null) ||
(this.context.Credentials.GetAppKey(context.Crypto) == null))
{
throw new AppCredentialsException();
}
var revokeRequest = new RevokeCardRequest(card.Id, RevocationReason.Unspecified);

var appId = this.context.Credentials.GetAppId();
var appKey = this.context.Credentials.GetAppKey(this.context.Crypto);


var fingerprint = this.context.Crypto.CalculateFingerprint(revokeRequest.Snapshot);
var signature = this.context.Crypto.Sign(fingerprint.GetValue(), appKey);

revokeRequest.AppendSignature(appId, signature);

/* to_ask
var requestSigner = new RequestSigner(this.context.Crypto);
requestSigner.AuthoritySign(revokeRequest, appId, appKey); */

await this.context.Client.RevokeCardAsync(revokeRequest);
}

/// <summary>
/// Revokes a global <see cref="VirgilCard"/> from Virgil Security services.
/// </summary>
Expand All @@ -247,6 +260,11 @@ public async Task RevokeGlobalAsync(VirgilCard card, VirgilKey key, IdentityVali

revokeRequest.AppendSignature(card.Id, signature.GetBytes());

/* to_ask
var requestSigner = new RequestSigner(this.context.Crypto);
requestSigner.AuthoritySign(revokeRequest, card.Id, key.PrivateKey);
*/

await this.context.Client.RevokeGlobalCardAsync(revokeRequest);
}

Expand Down
49 changes: 49 additions & 0 deletions SDK/Source/Virgil.SDK.Shared/Client/AddRelationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#region Copyright (C) Virgil Security Inc.
// Copyright (C) 2015-2016 Virgil Security Inc.
//
// Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// (1) Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
//
// (3) Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Virgil.SDK.Client
{
public class AddRelationRequest : SignableRequest<PublishCardSnapshotModel>
{
/// <summary>
/// Initializes a new instance of the <see cref="AddRelationRequest"/> class.
/// </summary>
/// <param name="snapshot">a snapshot model for <see cref="PublishCardRequest"/></param>
public AddRelationRequest(PublishCardSnapshotModel snapshot) : base(snapshot)
{
}
}
}
3 changes: 3 additions & 0 deletions SDK/Source/Virgil.SDK.Shared/Client/CardMetaModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class CardMetaModel
[JsonProperty("signs")]
public Dictionary<string, byte[]> Signatures { get; set; }

[JsonProperty("relations")]
public Dictionary<string, byte[]> Relations { get; set; }

[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }

Expand Down
51 changes: 51 additions & 0 deletions SDK/Source/Virgil.SDK.Shared/Client/DeleteRelationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#region Copyright (C) Virgil Security Inc.
// Copyright (C) 2015-2016 Virgil Security Inc.
//
// Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// (1) Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
//
// (3) Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Virgil.SDK.Client
{
public class DeleteRelationRequest : RevokeCardRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteRelationRequest"/> class.
/// </summary>
/// <param name="cardId">The card ID to be revoked.</param>
/// <param name="reason">The revocation reason.</param>
public DeleteRelationRequest(string cardId, RevocationReason reason) : base(cardId, reason)
{
}
}
}

Loading

0 comments on commit d4a9e5a

Please sign in to comment.