Logo Studenta

Formato para Informe de Herramientas Criptográficas de Clave Pública 200983

¡Este material tiene más páginas!

Vista previa del material en texto

Formato para Informe de Herramientas Criptográficas de Clave Pública 
 
Seguridad de la información II 
 
 
 
 
Lenguaje 1 
Nombre herramienta 
Tipo 
(paquete
, librería, 
clase, 
etc.) 
Funcionalidad 
 
Código ejemplo 
Python Scapy Librería Scapy es una 
completa 
herramienta 
interactiva de 
manipulación de 
paquetes escrita en 
Python por Philippe 
Biondi. Realiza 
principalmente dos 
funciones: enviar 
paquetes y recibir 
respuestas. 
Puede falsificar o 
decodificar 
paquetes de una 
variedad de 
protocolos, 
enviarlos, recibir 
respuestas, 
emparejar 
solicitudes con 
respuestas y 
Welcome to Scapy (2.4.4.dev221) 
>>> p = IP(dst="github.com")/ICMP() 
>>> p 
<IP frag=0 proto=icmp dst=Net('github.com') |<ICMP 
|>> 
>>> r = sr1(p) 
Begin emission: 
Finished sending 1 packets. 
 
Paul Alonso Hernández Holguín 200893 
devolver una lista 
de parejas de 
paquetes y una lista 
de paquetes no 
emparejados. 
Requests Librería Requests es una 
librería HTTP de 
Python que se 
utiliza para enviar 
peticiones 
HTTP/HTTPS 
fácilmente. La 
librería requests es 
una herramienta 
increíblemente útil 
y versátil para 
escribir scripts en 
Python que 
requieran 
interacción con 
servicios web. 
import requests 
requests.get('https://api.github.com') 
response = requests.get('https://api.github.com') 
if response.status_code == 200: 
 print('Success!') 
elif response.status_code == 404: 
 print('Not Found.') 
 
Cryptography Paquete Cryptography es un 
paquete que 
proporciona recetas 
criptográficas a los 
desarrolladores de 
Python. Esto incluye 
encriptación, 
hashing, generación 
de números 
aleatorios, firmas, 
así como cifrados 
por bloque y de 
flujo. 
>>> from cryptography.fernet import Fernet 
>>> # Put this somewhere safe! 
>>> key = Fernet.generate_key() 
>>> f = Fernet(key) 
 
Faker Librería Faker es un paquete 
de Python que 
genera datos falsos. 
Puede generar 
cualquier cosa, 
desde nombres, 
números de 
teléfono y 
direcciones hasta 
textos falsos, 
documentos XML, 
etc. 
from faker import Faker 
fake = Faker() 
 
fake.name() 
# 'Lucy Cechtelar' 
 
fake.address() 
# '426 Jordy Lodge 
# Cartwrightshire, SC 88120-6700' 
 
hashlib Módulo El módulo hashlib 
define una interfaz 
de programación 
para acceder a 
diferentes 
algoritmos 
criptográficos de 
hash. 
import hashlib 
m = hashlib.sha256() 
m.update(b"Nobody inspects") 
m.update(b" the spammish repetition") 
m.digest() 
 
hmac Algoritm
o 
El algoritmo HMAC 
se puede utilizar 
para verificar la 
integridad de la 
información 
transmitida entre 
aplicaciones o 
almacenada en un 
lugar 
potencialmente 
vulnerable. El 
algoritmo HMAC se 
puede utilizar para 
verificar la 
integridad de la 
información 
import hmac 
 
digest_maker = hmac.new(b'secret-shared-key-goes-
here') 
 
with open('lorem.txt', 'rb') as f: 
 while True: 
 block = f.read(1024) 
 if not block: 
 break 
 digest_maker.update(block) 
 
digest = digest_maker.hexdigest() 
print(digest) 
 
transmitida entre 
aplicaciones o 
almacenada en un 
lugar 
potencialmente 
vulnerable. 
 
Lenguaje 2 
Nombre herramienta 
Tipo 
(paquete
, librería, 
clase, 
etc.) 
Funcionalidad 
 
Código ejemplo 
 
Java 
Provider Clase Esta clase 
representa un 
"proveedor" para el 
API para seguridad 
de Java, donde un 
proveedor 
implementa algunas 
o todas las partes 
de Java Security. 
[Android.Runtime.Register("java/security/Provider", 
DoNotGenerateAcw=true)] 
public abstract class Provider: Java.Util.Properties 
 
Motor Clase Proporcionar 
operaciones 
criptográficas 
(como las 
empleadas en el 
firmado y el 
resumen de 
mensajes). 
Generar o 
proporcionar el 
material 
criptográfico (claves 
o parámetros) 
necesario para 
import java.security.*; 
import java.util.*; 
 
class InfoProveedores { 
 public static void main(String[] args) { 
 boolean listarProps = false; 
 if ( args.length > 0 && args[0].equals("-l") ) 
 listarProps=true; 
 System.out.println("-----------------------------
-------"); 
 System.out.println("Proveedores instalados en su 
sistema"); 
 System.out.println("-----------------------------
-------"); 
 Provider[] listaProv = Security.getProviders(); 
 
realizar las 
operaciones. 
 Generar objetos 
(almacenes de 
claves o 
certificados) que 
agrupen claves 
criptográficas de 
modo seguro. 
JAAS Paquete El servicio de 
autenticación y 
autorización Java™ 
(JAAS) es una 
extensión estándar 
del Java 2 Software 
Development Kit. 
Actualmente, Java 2 
proporciona 
controles de acceso 
basados en el 
código fuente 
(controles de 
acceso basados en 
dónde se originó el 
código y en quién 
firmó el código). 
grant codebase "file:./SampleAcn.jar" { 
 
 permission javax.security.auth.AuthPermission 
 "createLoginContext.Sample"; 
}; 
 
javax.crypto.spec Paquete Proporciona clases 
e interfaces para 
especificaciones de 
claves y parámetros 
de algoritmos. 
 
Las especificaciones 
de claves son 
representaciones 
transparentes de las 
byte[] encodedKey = Base64.decode(stringKey, 
Base64.DEFAULT); 
 SecretKey originalKey = new 
SecretKeySpec(encodedKey, 0, encodedKey.length, 
"AES"); 
 
https://www.tabnine.com/code/java/methods/javax.crypto.spec.SecretKeySpec/%3Cinit%3E
claves. Las claves se 
pueden especificar 
de un modo 
específico del 
algoritmo o en un 
formato de 
codificación 
independiente del 
algoritmo, como el 
ASN.1. 
javax.crypto.interface
s 
Paquete Proporciona 
interfaces para 
claves Diffie-
Hellman como se 
definen en el PKCS 
#3 de los 
laboratorios RSA. 
 
Las interfaces 
incluidas en este 
paquete son: 
 
 DHKey. Interfaz 
con una clave Diffie-
Hellman. 
 DHPrivateKey. 
Interfaz con una 
clave privada Diffie-
Hellman. 
 DHPublicKey. 
Interfaz con una 
clave pública Diffie-
Hellman. 
RawDHPrivateKey(final DHPrivateKey original) { 
 super(original); 
 x = original.getX(); 
 params = original.getParams(); 
} 
 
java.security Paquete El paquete 
java.security 
consiste 
MessageDigest md = MessageDigest.getInstance("SHA-1"); 
byte[] hashedPassword = md.digest("somepassword".getBytes()); 
 
https://www.tabnine.com/code/java/methods/javax.crypto.interfaces.DHPrivateKey/getX
https://www.tabnine.com/code/java/methods/javax.crypto.interfaces.DHPrivateKey/getParams
básicamente en 
clases abstractas e 
interfaces que 
encapsulan 
conceptos de 
seguridad como 
certificados, claves, 
resumenes de 
mensajes y firmas 
digitales. 
SecureRandom random = new SecureRandom(); 
byte[] salt = new byte[16]; 
random.nextBytes(salt); 
 
KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128); 
SecretKeyFactory factory = 
SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 
 
byte[] hash = factory.generateSecret(spec).getEncoded(); 
 
Lenguaje 3 
Nombre herramienta 
Tipo 
(paquete
, librería, 
clase, 
etc.) 
Funcionalidad 
 
Código ejemplo 
C++ Libgcrypt Bibliotec
a 
Libgcrypt es una 
biblioteca de 
criptografía 
desarrollada como 
un módulo 
separado de 
GnuPG. También se 
puede usar 
independientement
e de GnuPG, pero 
depende de su 
biblioteca de 
informes de errores 
Libgpg-error. 
Proporciona 
funciones para 
todos los bloques 
de construcción 
criptográficos 
fundamentales. 
• • #include<stdio.h> 
• #include<gcrypt.h> 
• 
• int main() { 
• FILE *f = NULL; 
• gcry_sexp_t rsa_parms = NULL; 
• gcry_sexp_t rsa_keypair = NULL; 
• gcry_error_t err = 0; 
• char *buffer; 
• size_t length = 4; 
• size_t offset = 0; 
• err = gcry_control 
(GCRYCTL_SUSPEND_SECMEM_WARN); 
• err |= gcry_control (GCRYCTL_INIT_SECMEM, 
16384, 0); 
• err |= gcry_control 
(GCRYCTL_RESUME_SECMEM_WARN); 
• err |= gcry_control 
(GCRYCTL_INITIALIZATION_FINISHED, 0); 
• if(err) { 
• fprintf(stderr,"gcrypt: failed 
initialization"); 
• exit(0); 
• } 
• err = gcry_sexp_build(&rsa_parms, NULL, 
"(genkey(rsa (nbits 4:4096)(rsa-use-e 1:1)))"); 
• if (err) { 
• fprintf(stderr,"gcrypt: failed 
initialization"); 
• exit(0); 
• } 
Crypto++ Bibliotec
a 
Crypto++ Library es 
una biblioteca 
gratuita de clase 
C++ de esquemas 
criptográficos. 
#include <iostream> 
#include <iomanip> 
 
#include "modes.h" 
#include "aes.h" 
#include "filters.h" 
 
int main(int argc, char* argv[]) { 
 
 //Key and IV setup 
 //AES encryption uses a secret key of a variable 
length (128-bit, 196-bit or 256- 
 //bit). This key is secretly exchanged between 
two parties before communication 
 //begins. DEFAULT_KEYLENGTH= 16 bytes 
 CryptoPP::byte key[ 
CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[ 
CryptoPP::AES::BLOCKSIZE ]; 
 memset( key, 0x00, 
CryptoPP::AES::DEFAULT_KEYLENGTH ); 
 memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE ); 
http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html
http://www.opengroup.org/onlinepubs/009695399/functions/exit.html
http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html
http://www.opengroup.org/onlinepubs/009695399/functions/exit.html
 
Elliptic-curve 
cryptography 
Algoritm
o 
Es una variante de 
la criptografía 
asimétrica o de 
clave pública 
basada en las 
matemáticas de las 
curvas elípticas. 
#include "ECC.h" 
 
using namespace std; 
 
//Algorithm 4.24 Key pair generation 
void convertElementToInt(Integer& result,ExtensionField::Element& R, 
Integer& mod, ellipticCurveFq& E_Fq) 
{ 
 result=0; 
 ExtensionField::Element P; 
 if (R.size()) 
 { 
 E_Fq.field->Fp_X.assign(P, R); 
 E_Fq.field->Fp_X.setdegree(P); 
 for(unsigned long l=0;l<P.size();++l) 
 { 
 result+=P[l]*(l+1);//if P[l] loses precision, that's not a 
problem 
 result=result%mod; 
 } 
 } 
} 
Bcrypt Bibliotec
a 
Bcrypt es una 
función de hashing 
de contraseñas 
#include <stdio.h> 
#include <stdlib.h> 
#include <stdint.h> 
#include <sys/types.h> 
#include <string.h> 
 
#include "node_blf.h" 
 
#include "bcrypt.h" 
#include "openbsd.h" 
 
#ifdef _WIN32 
#define snprintf _snprintf 
#endif 
 
//#if !defined(__APPLE__) && !defined(__MACH__) 
//#include "bsd/stdlib.h" 
//#endif 
 
/* This implementation is adaptable to current computing power. 
 * You can have up to 2^31 rounds which should be enough for some 
 * time to come. 
 */ 
 
static void encode_base64(u_int8_t *, u_int8_t *, u_int16_t); 
static void decode_base64(u_int8_t *, u_int16_t, u_int8_t *); 
 
const static char* error = ":"; 
 
const static u_int8_t Base64Code[] = 
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678
9"; 
 
const static u_int8_t index_64[128] = { 
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
 255, 255, 255, 255, 255, 255, 0, 1, 54, 55, 
 56, 57, 58, 59, 60, 61, 62, 63, 255, 255, 
 255, 255, 255, 255, 255, 2, 3, 4, 5, 6, 
 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 
 255, 255, 255, 255, 255, 255, 28, 29, 30, 
 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 
 51, 52, 53, 255, 255, 255, 255, 255 
}; 
Botan Bibliotec
a 
Botan es una 
biblioteca 
criptográfica y TLS 
con licencia BSD 
escrita en C++ 11. 
Proporciona una 
amplia variedad de 
algoritmos, 
formatos y 
protocolos 
criptográficos, p. 
SSL y TLS. 
#include <vector> 
#include <sha2_32.h> 
 
using namespace Botan; 
 
secure_vector<byte> somefunction(std::vector<byte> 
input) { 
 SHA_256 sha; 
 return sha.process(input); 
} 
 
Digestpp Librería Biblioteca hash de 
mensajes de solo 
encabezado de C++ 
11. 
#ifndef DIGESTPP_ALGORITHM_BLAKE_HPP 
#define DIGESTPP_ALGORITHM_BLAKE_HPP 
 
#include "../hasher.hpp" 
#include "detail/blake_provider.hpp" 
#include "mixin/blake_mixin.hpp" 
 
namespace digestpp 
{

Continuar navegando