存储

时间:2016-09-28 13:55:20

标签: .net encoding cryptography ecdsa key-pair

我在.NET中实现ECDSA密钥和证书,我需要存储密钥,以便我可以使用新的签名重用它们。 使用RSA我使用的是RSACryptoServiceProvider类,但我没有看到任何与ECDsa类似的ECDsaCng类。

我只看过DSACryptoServiceProvider和一个旧的ECDsaCryptoServiceProvider到Framework 4.3(有点旧)。

有人知道如何在RSA中存储ECDSA密钥吗?

1 个答案:

答案 0 :(得分:3)

假设你的意思是你想将一个密钥持久存储到OS密钥存储区(使用命名密钥的RSACryptoServiceProvider),那么CNG的接口就会有所不同:

var app = angular.module('myApp', ['ngMaterial']);
app.controller('mainCtrl', function($scope,msgService) {

   $scope.name = "Observer App Example";
   $scope.msg = 'Message';
   $scope.broadcastFn = function(){
        msgService.broadcast($scope.msg);
   }


});

app.component("boxA",  {
      bindings: {},
      controller: function(msgService) {
        var boxA = this;
        boxA.msgService = msgService;

        boxA.msg = '';

        var boxASubscription = boxA.msgService.subscribe(function(obj) { 
            console.log('Listerner A');
          boxA.msg = obj;
                });

        boxA.unsubscribe = function(){
            console.log('Unsubscribe A');
            boxASubscription.dispose();
        };

      },
      controllerAs: 'boxA',
      templateUrl: "/boxa"
})
app.component("boxB",  {
      bindings: {},
      controller: function(msgService) {
        var boxB = this;
        boxB.msgService = msgService;

        boxB.msg = '';
        var boxBSubscription = boxB.msgService.subscribe(function(obj) { 
            console.log('Listerner B');
          boxB.msg = obj;
                });

        boxB.unsubscribe=function(){
            console.log('Unsubscribe B');
          boxBSubscription.dispose();
        };
      },
      controllerAs: 'boxB',
      templateUrl: "/boxb"
})

app.factory('msgService', ['$http', function($http){
    var msgSubject = new Rx.Subject();
    return{
        subscribe:function(subscription){
            return msgSubject.subscribe(subscription);
        },
        broadcast:function(msg){
        console.log('success');
            msgSubject.onNext(msg);
        }
    }   
}])

如果您想要像RSAParameters一样进行导出/导入,那么.NET Core中会出现该功能,但.NET Framework中尚未出现此功能。