com.tmobile.oss.security.taap.jwe_4_8
1.0.0
com.tmobile.oss.security.taap.jwe
Additional DetailsPlease use latest version
dotnet add package com.tmobile.oss.security.taap.jwe_4_8 --version 1.0.0
NuGet\Install-Package com.tmobile.oss.security.taap.jwe_4_8 -Version 1.0.0
<PackageReference Include="com.tmobile.oss.security.taap.jwe_4_8" Version="1.0.0" />
paket add com.tmobile.oss.security.taap.jwe_4_8 --version 1.0.0
#r "nuget: com.tmobile.oss.security.taap.jwe_4_8, 1.0.0"
// Install com.tmobile.oss.security.taap.jwe_4_8 as a Cake Addin
#addin nuget:?package=com.tmobile.oss.security.taap.jwe_4_8&version=1.0.0
// Install com.tmobile.oss.security.taap.jwe_4_8 as a Cake Tool
#tool nuget:?package=com.tmobile.oss.security.taap.jwe_4_8&version=1.0.0
JSON Web Encryption (JWE) component o .NET 4.8 using RSA or EC keys.
Obtains public RSA and/or EC keys from a JWKS REST Service o Caches the public keys o Refreshes the public keys each hour.
Uses the public key to encrypt a PII string and creates a JWE encode string o For RSA key, uses RSA_OAEP_256 and A256GCM o For EC key, uses ECDH_ES_A256KW and A256GCM
Uses the private key to decrypt a JWE encode string o The public Key Id must be the same as the private Key Id.
C# ASP.NET MVC Sample Code:
appsettings.json
{ "EncryptionOptions": { "JwksUrl": "http://localhost:31102/api/jwks/v1/lab01/getjsonwebkeys", "CacheDurationSeconds": 3600 // 1 hour } }
Controller
public class HomeController : Controller
{
private readonly Encryption encryption;
public HomeController(Encryption encryption)
{
this.encryption = encryption;
}
[HttpGet]
public IActionResult Index()
{
var encryptedJweViewModel = new EncryptedJweViewModel();
encryptedJweViewModel.PhoneNumber = "(555) 555-5555";
encryptedJweViewModel.ErrorMessage = " ";
encryptedJweViewModel.EncryptedJwe = string.Empty;
return View(encryptedJweViewModel);
}
[HttpPost]
public async Task<IActionResult> Index(string submitButton, string encryptedJwe, EncryptedJweViewModel encryptedJweViewModel)
{
try
{
if (submitButton == "Encrypt")
{
encryptedJweViewModel.EncryptedJwe = await this.encryption.EncryptAsync(encryptedJweViewModel.PhoneNumber);
}
else if (submitButton == "Decrypt")
{
encryptedJweViewModel.DecryptedPhoneNumber = await this.encryption.DecryptAsync(encryptedJwe);
}
}
catch(Exception ex)
{
encryptedJweViewModel.DecryptedPhoneNumber = string.Empty;
encryptedJweViewModel.ErrorMessage = ex.Message;
if (ex.InnerException != null)
{
encryptedJweViewModel.ErrorMessage += " " + ex.InnerException.Message;
}
}
return View(encryptedJweViewModel);
}
Model View
public class EncryptedJweViewModel
{
[DisplayName("Enter in a phone number:")]
public string PhoneNumber { get; set; }
[DisplayName("Encrypted JWE:")]
public string EncryptedJwe { get; set; }
[DisplayName("Decrypted JWE:")]
public string DecryptedPhoneNumber { get; set; }
[DisplayName("Error message:")]
public string ErrorMessage { get; set; } }
View
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "encryptionForm" })) { <p> <label class="errorMessage">@Model.ErrorMessage</label> </p> <p> <label>Enter in a phone number:</label><br /> @Html.TextBoxFor(m => m.PhoneNumber)<br /> <input type="submit" name="submitButton" value="Encrypt"> </p> <p> <label>Encrypted JWE:</label><br /> <textarea name="encryptedJwe" form="encryptionForm">@Model.EncryptedJwe</textarea> <input type="submit" name="submitButton" value="Decrypt"> </p> <p> <label>Decrypted phone number:</label><br /> <input type="text" name="decryptedPhoneNumber" value="@Model.DecryptedPhoneNumber" /> </p> }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
- jose-jwt (>= 2.5.0)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.3)
- Microsoft.IdentityModel.Tokens (>= 6.5.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Net.Http (>= 4.3.4)
- System.Runtime (>= 4.3.1)
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
- System.Security.Cryptography.Algorithms (>= 4.3.1)
- System.Security.Cryptography.X509Certificates (>= 4.3.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
Initial release