コード例 #1
0
 protected override void SetItems(IReadOnlyList <byte[]> data)
 {
     VuId     = new Guid(data[0]);
     CvkPub   = data[1].Length != 0 ? C25519Key.Parse(data[1]) : null;
     CVKi     = new BigInteger(data[2], true, true);
     CvkiAuth = AesKey.Parse(data[3]);
 }
コード例 #2
0
 public VendorConfig CreateVendorConfig()
 {
     return(new VendorConfig
     {
         PrivateKey = C25519Key.Parse(Convert.FromBase64String(PrivateKey)),
         SecretKey = AesKey.Parse(SecretKey)
     });
 }
コード例 #3
0
 public KeyIdVault Map()
 {
     return(new KeyIdVault
     {
         KeyId = this.KeyId,
         Key = C25519Key.Parse(Convert.FromBase64String(Key))
     });
 }
コード例 #4
0
        public async Task <C25519Key> GetPublic()
        {
            var response = await _client.GetAsync("api/public");

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new HttpRequestException(response.ToString());
            }

            var keyText = await response.Content.ReadAsStringAsync();

            return(C25519Key.Parse(Convert.FromBase64String(keyText)));
        }
コード例 #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options =>
            {
                options.ModelBinderProviders.Insert(0, new C25519PointBinderProvider());
            });

            var settings = new Settings();

            Configuration.Bind("Settings", settings);

            services.AddSingleton(settings);
            services.AddHttpContextAccessor();
            services.AddMemoryCache();
            services.AddTransient <IEmailClient, MailKitClient>();
            services.AddTransient <OrkConfig>();
            services.AddSignalR();

            services.AddSpaStaticFiles(opt => opt.RootPath = "Client/dist");

            if (settings.Features.Metrics)
            {
                services.AddMetrics();
            }

            if (settings.Features.Throttling)
            {
                services.ConfigureThrottling();
            }

            if (settings.Features.Memory)
            {
                services.AddTransient <IKeyManagerFactory, MemoryFactory>();
            }
            else
            {
                services.AddTransient <IKeyManagerFactory, SimulatorFactory>();
            }

            services.AddCors();

            var privString = "AOAxMtmYfyI98Tr5jiQ77kZGA3goBctEWnDFTWnSOzol3pIbKWvLkkW83s55zJNczOxcbKXdeRSheFXmlDeQWS+KTCkfERyiI5J1i8Xlwe4clgY10LAfV0Ds9xP4QOhK";

            var priv      = C25519Key.Parse(privString);
            var pubString = priv.GetPublic().ToString();
        }
コード例 #6
0
        public async Task <ActionResult <TideResponse> > Add([FromRoute] Guid vuid, [FromRoute] Guid keyId, [FromBody] string[] data)
        {
            var signature = FromBase64(data[3]);
            var account   = new CvkVault
            {
                VuId     = vuid,
                CvkPub   = C25519Key.Parse(FromBase64(data[0])),
                CVKi     = GetBigInteger(data[1]),
                CvkiAuth = AesKey.Parse(FromBase64(data[2]))
            };

            if (_features.Voucher)
            {
                var signer = await _keyIdManager.GetById(keyId);

                if (signer == null)
                {
                    return(BadRequest("Signer's key must be defined"));
                }

                if (!signer.Key.Verify(_config.Guid.ToByteArray().Concat(vuid.ToByteArray()).ToArray(), signature))
                {
                    return(BadRequest("Signature is not valid"));
                }
            }

            _logger.LogInformation("New cvk for {0} with pub {1}", vuid, data[0]);

            var resp = await _managerCvk.SetOrUpdate(account);

            if (!resp.Success)
            {
                return(resp);
            }

            var m = Encoding.UTF8.GetBytes(_config.UserName + vuid.ToString());
            //TODO: The ork should not send the orkid because the client should already know
            var signOrk = Convert.ToBase64String(_config.PrivateKey.Sign(m));

            resp.Content = new { orkid = _config.UserName, sign = signOrk };

            return(resp);
        }
コード例 #7
0
 public C25519Key GetPublicKey()
 {
     return(C25519Key.Parse(Public));
 }
コード例 #8
0
 public List <C25519Key> GetPublics() => Publics.Where(pub => !string.IsNullOrWhiteSpace(pub))
 .Select(pub => C25519Key.Parse(pub.Trim())).ToList();
コード例 #9
0
 public C25519Key GetPrivateKey() => C25519Key.Parse(Convert.FromBase64String(PrivateKey));