Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix and U2F as separate project #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Defs/Defs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xdk.IntelXdk", "Xdk.IntelXd
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xdk.JavaScript", "Xdk.JavaScript\Xdk.JavaScript.csproj", "{A7B1398F-706F-4057-9185-5E4B305096BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIDO", "FIDO\FIDO.csproj", "{7FD68F02-F406-4F7A-9883-865E292B5982}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
36 changes: 36 additions & 0 deletions Defs/FIDO/ErrorCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
[JsType(JsMode.Json)]
public enum ErrorCode
{
/// <summary>
/// Success. Not used in errors but reserved
/// </summary>
OK = 0,
/// <summary>
/// An error otherwise not enumerated here
/// </summary>
OtherError = 1,
/// <summary>
/// The request cannot be processed
/// </summary>
BadRequest = 2,
/// <summary>
/// Client configuration is not supported
/// </summary>
ConfigurationUnsupported = 3,
/// <summary>
/// The presented device is not eligible for this request. For a registration request this may mean that the token is already registered, and
/// for a sign request it may mean the token does not know the presented key handle.
/// </summary>
DeviceIneligible = 4,
/// <summary>
/// Timeout reached before request could be satisfied
/// </summary>
Timeout = 5,
}
}

62 changes: 62 additions & 0 deletions Defs/FIDO/FIDO.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7FD68F02-F406-4F7A-9883-865E292B5982}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SharpKit.FIDO</RootNamespace>
<AssemblyName>U2F</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>500</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ErrorCode.cs" />
<Compile Include="RegisterRequest.cs" />
<Compile Include="RegisterResponse.cs" />
<Compile Include="Request.cs" />
<Compile Include="Response.cs" />
<Compile Include="ResponseData.cs" />
<Compile Include="SignRequest.cs" />
<Compile Include="SignResponse.cs" />
<Compile Include="U2F.cs" />
<Compile Include="U2FWindow.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<ProjectReference Include="..\JavaScript\JavaScript.csproj">
<Project>{5A90FAC8-67DA-4823-B114-91F5A26B2FE9}</Project>
<Name>JavaScript</Name>
</ProjectReference>
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions Defs/FIDO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Reflection;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("U2F")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("peter")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

30 changes: 30 additions & 0 deletions Defs/FIDO/RegisterRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class RegisterRequest
{
/// <summary>
/// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2".
/// </summary>
[JsProperty(Name = "version", NativeField = true)]
public JsString Version { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "challenge", NativeField = true)]
public JsString Challenge { get; set; }

/// <summary>
/// The application id that the RP asserts. The new key pair that the U2F token generates will be associated with this application id.
/// (For application id details see [U2FAppFacet] in bibliography).
/// </summary>
[JsProperty(Name = "appId", NativeField = true)]
public JsString AppID { get; set; }

}
}

29 changes: 29 additions & 0 deletions Defs/FIDO/RegisterResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
/// <summary>
/// Error or RegisterResponse or SignResponse
/// - all in one class
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class RegisterResponse
{
[JsProperty(Name = "errorCode", NativeField = true)]
public ErrorCode ErrorCode { get; set; }

[JsProperty(Name = "errorMessage", NativeField = true)]
public JsString ErrorMessage { get; set; }

[JsProperty(Name = "registrationData", NativeField = true)]
public JsString RegistrationData { get; set; }

/// <summary>
/// The client data created by the FIDO client, websafe-base64 encoded
/// </summary>
[JsProperty(Name = "clientData", NativeField = true)]
public JsString ClientData { get; set; }
}
}

43 changes: 43 additions & 0 deletions Defs/FIDO/Request.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
/// <summary>
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class Request
{
/// <summary>
/// The type of request, either "u2f_register_request" or "u2f_sign_request".
/// </summary>
[JsProperty(Name = "type", NativeField = true)]
public JsString Type { get; set; }

/// <summary>
/// A list of SignRequest dictionaries, one for each token already registered with this RP.
/// </summary>
[JsProperty(Name = "signRequests", NativeField = true)]
public SignRequest[] SignRequest { get; set; }

/// <summary>
/// A list of RegisterRequest dictionaries, one for each protocol version that the RP is willing to register.
/// </summary>
[JsProperty(Name = "registerRequests", NativeField = true)]
public RegisterRequest[] RegisterRequest { get; set; }

/// <summary>
/// A timeout for the FIDO Client's processing, in seconds
/// </summary>
[JsProperty(Name = "timeoutSeconds", NativeField = true)]
public int TimeoutSeconds { get; set; }

/// <summary>
/// An integer identifying this request from concurrent requests.
/// </summary>
[JsProperty(Name = "requestId", NativeField = true)]
public int RequestId { get; set; }
}
}

31 changes: 31 additions & 0 deletions Defs/FIDO/Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
/// <summary>
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class Response
{
/// <summary>
/// The type of request, either "u2f_register_request" or "u2f_sign_request".
/// </summary>
[JsProperty(Name = "type", NativeField = true)]
public JsString Type { get; set; }

/// <summary>
/// Error or RegisterResponse or SignResponse
/// </summary>
[JsProperty(Name = "responseData", NativeField = true)]
public ResponseData ResponseData { get; set; }

/// <summary>
/// An integer identifying this request from concurrent requests.
/// </summary>
[JsProperty(Name = "requestId", NativeField = true)]
public int RequestId { get; set; }
}
}

60 changes: 60 additions & 0 deletions Defs/FIDO/ResponseData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
/// <summary>
/// Error or RegisterResponse or SignResponse
/// - all in one class
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class ResponseData
{
#region Error

[JsProperty(Name = "errorCode", NativeField = true)]
public ErrorCode ErrorCode { get; set; }

[JsProperty(Name = "errorMessage", NativeField = true)]
public JsString ErrorMessage { get; set; }

#endregion

#region RegisterResponse

[JsProperty(Name = "registrationData", NativeField = true)]
public JsString RegistrationData { get; set; }

//clientData

#endregion

#region SignResponse

/// <summary>
/// The keyHandle of the SignRequest that was processed.
/// </summary>
[JsProperty(Name = "keyHandle", NativeField = true)]
public JsString KeyHandle { get; set; }

/// <summary>
/// The raw response from U2F device, websafe-base64 encoded.
/// </summary>
[JsProperty(Name = "signatureData", NativeField = true)]
public JsString SignatureData { get; set; }

//clientData

#endregion

//Shared in RegisterResponse and SingResposne
/// <summary>
/// The client data created by the FIDO client, websafe-base64 encoded
/// </summary>
[JsProperty(Name = "clientData", NativeField = true)]
public JsString ClientData { get; set; }

}
}

36 changes: 36 additions & 0 deletions Defs/FIDO/SignRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.FIDO
{
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class SignRequest
{
/// <summary>
/// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2".
/// </summary>
[JsProperty(Name = "version", NativeField = true)]
public JsString Version { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "challenge", NativeField = true)]
public JsString Challenge { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "keyHandle", NativeField = true)]
public JsString KeyHandle { get; set; }

/// <summary>
/// The application id that the RP asserts. The new key pair that the U2F token generates will be associated with this application id.
/// (For application id details see [U2FAppFacet] in bibliography).
/// </summary>
[JsProperty(Name = "appId", NativeField = true)]
public JsString AppID { get; set; }

}
}

Loading