using System;
using System.Collections.Generic;
using System.Reflection;
Definir proveedores y clases criptográficas en ASP.NET.
A continuación se describen las circunstancias bajo las cuales la siguiente solución tiene sentido:
Se está desarrollando una aplicación en ASP.NET.
La aplicación hará uso de métodos criptográficos.
Debe usarse mecanismos criptográficos pre-existentes. [1]
Existen diversas clases para el uso criptográfico en el framework .NET, podemos listar todos los proveedores y clases que son soportadas por el framework a través del uso de Reflection.
Primero usamos los nombres de espacio involucrados en la solución:
using System;
using System.Collections.Generic;
using System.Reflection;
Declaramos nuestro nombre de espacios y definimos la entrada para el programa:
namespace CryptographicClass {
class Program {
static void Main(string[] args) {
Cargamos el archivo mscorlib.dll, el cual contiene todas las clases y métodos del núcleo de .NET:
Assembly assembly = Assembly.Load("mscorlib.dll");
Definimos una lista donde agregaremos las clases criptográficas:
List<string> classes = new List<string>();
Recorremos todas las clases soportadas por .NET:
foreach (Type type in assembly.GetTypes()) {
Si el espacio de nombres de la clase pertenece a la biblioteca criptográfica, entonces agregamos el nombre de la clase a la lista definida anteriormente:
if (type.Namespace == "System.Security.Cryptography") {
classes.Add(type.Name);
}
}
Ordenamos alfabéticamente la lista y la imprimimos:
classes.Sort();
foreach (string classname in classes) {
Console.WriteLine(classname);
}
}
}
}
En la siguiente tabla encontrará un resumen de las clases criptográficas y el algoritmo que implementan:
Nombre simple | Clase | Algoritmo implementado |
---|---|---|
3DES, Triple DES, TripleDES |
System.Security. |
TripleDESCryptoServiceProvider |
AES |
System.Security. |
AesCryptoServiceProvider |
AesManaged |
System.Security. |
AesManaged |
System.Security. |
RSACryptoServiceProvider |
|
DES |
System.Security. |
DESCryptoServiceProvider |
DSA |
System.Security. |
DSACryptoServiceProvider |
ECDH |
ECDiffieHellman, ECDiffieHellmanCng,
System.Security. |
ECDiffieHellmanCng |
ECDsa, ECDsaCng |
System.Security. |
ECDsaCng |
System.Security. |
SHA1CryptoServiceProvider |
|
HMAC |
System.Security. |
HMACSHA1 |
HMACMD5 |
System.Security. |
HMACMD5 |
HMACRIPEMD160 |
System.Security. |
HMACRIPEMD160 |
HMACSHA1 |
System.Security. |
HMACSHA1 |
HMACSHA256 |
System.Security. |
HMACSHA256 |
HMACSHA384 |
System.Security. |
HMACSHA384 |
HMACSHA512 |
System.Security. |
HMACSHA512 |
System.Security. |
MACSHA1 |
|
MACTripleDES |
System.Security. |
MACTripleDES |
MD5 |
System.Security. |
MD5CryptoServiceProvider |
System.Security. |
MD5Cng |
|
System.Security. |
RNGCryptoServiceProvider |
|
RC2 |
System.Security. |
RC2CryptoServiceProvider |
Rijndael |
System.Security. |
RijndaelManaged |
RIPEMD160, RIPEMD-160 |
System.Security. |
RIPEMD160Managed |
RSA |
System.Security. |
RSACryptoServiceProvider |
SHA, SHA1 |
System.Security. |
SHA1CryptoServiceProvider |
System.Security. |
SHA1Cng |
|
SHA256, SHA-256 |
System.Security. |
SHA256Managed |
System.Security. |
SHA256Cng |
|
System.Security. |
SHA256CryptoServiceProvider |
|
SHA384, SHA-384 |
System.Security. |
SHA384Managed |
System.Security. |
SHA384Cng |
|
System.Security. |
SHA384CryptoServiceProvider |
|
SHA512, SHA-512 |
System.Security. |
SHA512Managed |
System.Security. |
SHA512Cng |
|
System.Security. |
SHA512CryptoServiceProvider |
|
System.Security. |
System.Security. |
Copyright © 2021 Fluid Attacks, We hack your software. All rights reserved.