如何在Flutter中从RSA私钥生成令牌?

huangapple go评论84阅读模式
英文:

How to generate a token from a RSA private key in Flutter?

问题

import 'dart:convert';
import 'package:crypto_keys/crypto_keys.dart';
import 'package:jose/jose.dart';
import 'package:x509/x509.dart';

String pkey = "XXXXXXXXXXXXXsfds";

void keyGenerator() async {
  await example2();
}

void example2() async {
  var builder = JsonWebSignatureBuilder();

  builder.stringContent = 'It is me';

  builder.setProtectedHeader('createdAt', DateTime.now().toIso8601String());

  builder.addRecipient(
      JsonWebKey.fromJson({
        'kty': 'RSA',
        'kid': pkey,
      }),
      algorithm: 'RS256');

  var jws = builder.build();

  print('jws compact serialization: ${jws.toCompactSerialization()}');
  print('jws json serialization: ${jws.toJson()}');
}

void tokenGenerator() {
  var builder = JWTBuilder();
  var token = builder
    ..audience = "live-tv"
    ..issuedAt = DateTime.now()
    ..expiresAt = DateTime.now().add(Duration(minutes: 3))
    ..getToken();

  var signer = JWTRsaSha256Signer(privateKey: RSAPrivateKey.fromString(pkey));

  var signedToken = builder.getSignedToken(signer);
  print("token");
  print(signedToken);

  var stringToken = signedToken.toString();

  var decodedToken = JWT.parse(stringToken);

  print(decodedToken.verify(signer));
}

Note: The provided code snippets have been translated from the original content you provided.

英文:

Hi Guys I am really confused about so many things.All I know is that I have to generate a token at the end of the day.I am given some RSA private key which is some "XYZ............dsdsfm",(obviously I can't reveal it because of security issues),from there I have to generate some token which will serve as a header for authorisation of my API http request.

The problem is these internet related stuff of JsonWebKey and all that is not in my domain,but still I tried learning them but it is not very clear.I tried to implement some code which was written in Java by someone (and that guy knows only Java and not flutter),in flutter.

For Flutter implementation I tried two plugin in pub.dev...But I am not getting the proper output.

The first one was https://pub.dev/packages/jose>I tried what is similar in the example page of it as shown:

import 'dart:convert';
import 'dart:io';
import 'package:crypto_keys/crypto_keys.dart';
import 'package:jose/jose.dart';
import 'package:x509/x509.dart';
String pkey="XXXXXXXXXXXXXsfds";
void keyGenerator() async {
//await example1();
await example2();
//  await example3();
//  await example4();
//  await example5();
// await example6();
//  await example7();
//  await example8();
}
// decode and verify a JWS
void example1() async {
var encoded = pkey;
// create a JsonWebSignature from the encoded string
var jws = JsonWebSignature.fromCompactSerialization(encoded);
// extract the payload
var payload = jws.unverifiedPayload;
print('content of jws: ${payload.stringContent}');
print('protected parameters: ${payload.protectedHeader.toJson()}');
// create a JsonWebKey for verifying the signature
var jwk = JsonWebKey.fromJson({
'kty': 'RSA',
'alg': 'RS256',
});
var keyStore = JsonWebKeyStore()..addKey(jwk);
// verify the signature
var verified = await jws.verify(keyStore);
print('signature verified: $verified');
}
// create a JWS
void example2() async {
// create a builder
var builder = JsonWebSignatureBuilder();
// set the content
builder.stringContent = 'It is me';
// set some protected header
builder.setProtectedHeader('createdAt', DateTime.now().toIso8601String());
// add a key to sign, you can add multiple keys for different recipients
builder.addRecipient(
JsonWebKey.fromJson({
'kty': 'RSA',
'kid': pkey,
}),
algorithm: 'RS256');
// build the jws
var jws = builder.build();
// output the compact serialization
print('jws compact serialization: ${jws.toCompactSerialization()}');
// output the json serialization
print('jws json serialization: ${jws.toJson()}');
}
// decode and decrypt a JWE
void example3() async {
var encoded = 'eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.'
'UGhIOguC7IuEvf_NPVaXsGMoLOmwvc1GyqlIKOK1nN94nHPoltGRhWhw7Zx0-kFm'
'1NJn8LE9XShH59_i8J0PH5ZZyNfGy2xGdULU7sHNF6Gp2vPLgNZ__deLKxGHZ7Pc'
'HALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3YvkkysZIF'
'NPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPhcCdZ6XDP0_F8'
'rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPgwCp6X-nZZd9OHBv'
'-B3oWh2TbqmScqXMR4gp_A.'
'AxY8DCtDaGlsbGljb3RoZQ.'
'KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.'
'9hH0vgRfYgPnAHOd8stkvw';
// create a JsonWebEncryption from the encoded string
var jwe = JsonWebEncryption.fromCompactSerialization(encoded);
// create a JsonWebKey for decrypting the signature
var jwk = JsonWebKey.fromJson(
{
'kty': 'RSA',
'n': 'sXchDaQebHnPiGvyDOAT4saGEUetSyo9MKLOoWFsueri23bOdgWp4Dy1Wl'
'UzewbgBHod5pcM9H95GQRV3JDXboIRROSBigeC5yjU1hGzHHyXss8UDpre'
'cbAYxknTcQkhslANGRUZmdTOQ5qTRsLAt6BTYuyvVRdhS8exSZEy_c4gs_'
'7svlJJQ4H9_NxsiIoLwAEk7-Q3UXERGYw_75IDrGA84-lA_-Ct4eTlXHBI'
'Y2EaV7t7LjJaynVJCpkv4LKjTTAumiGUIuQhrNhZLuF_RJLqHpM2kgWFLU'
'7-VTdL1VbC2tejvcI2BlMkEpk1BzBZI0KQB0GaDWFLN-aEAw3vRw',
'e': 'AQAB',
'd': 'VFCWOqXr8nvZNyaaJLXdnNPXZKRaWCjkU5Q2egQQpTBMwhprMzWzpR8Sxq'
'1OPThh_J6MUD8Z35wky9b8eEO0pwNS8xlh1lOFRRBoNqDIKVOku0aZb-ry'
'nq8cxjDTLZQ6Fz7jSjR1Klop-YKaUHc9GsEofQqYruPhzSA-QgajZGPbE_'
'0ZaVDJHfyd7UUBUKunFMScbflYAAOYJqVIVwaYR5zWEEceUjNnTNo_CVSj'
'-VvXLO5VZfCUAVLgW4dpf1SrtZjSt34YLsRarSb127reG_DUwg9Ch-Kyvj'
'T1SkHgUWRVGcyly7uvVGRSDwsXypdrNinPA4jlhoNdizK2zF2CWQ',
'p': '9gY2w6I6S6L0juEKsbeDAwpd9WMfgqFoeA9vEyEUuk4kLwBKcoe1x4HG68'
'ik918hdDSE9vDQSccA3xXHOAFOPJ8R9EeIAbTi1VwBYnbTp87X-xcPWlEP'
'krdoUKW60tgs1aNd_Nnc9LEVVPMS390zbFxt8TN_biaBgelNgbC95sM',
'q': 'uKlCKvKv_ZJMVcdIs5vVSU_6cPtYI1ljWytExV_skstvRSNi9r66jdd9-y'
'BhVfuG4shsp2j7rGnIio901RBeHo6TPKWVVykPu1iYhQXw1jIABfw-MVsN'
'-3bQ76WLdt2SDxsHs7q7zPyUyHXmps7ycZ5c72wGkUwNOjYelmkiNS0',
'dp': 'w0kZbV63cVRvVX6yk3C8cMxo2qCM4Y8nsq1lmMSYhG4EcL6FWbX5h9yuv'
'ngs4iLEFk6eALoUS4vIWEwcL4txw9LsWH_zKI-hwoReoP77cOdSL4AVcra'
'Hawlkpyd2TWjE5evgbhWtOxnZee3cXJBkAi64Ik6jZxbvk-RR3pEhnCs',
'dq': 'o_8V14SezckO6CNLKs_btPdFiO9_kC1DsuUTd2LAfIIVeMZ7jn1Gus_Ff'
'7B7IVx3p5KuBGOVF8L-qifLb6nQnLysgHDh132NDioZkhH7mI7hPG-PYE_'
'odApKdnqECHWw0J-F0JWnUd6D2B_1TvF9mXA2Qx-iGYn8OVV1Bsmp6qU',
'qi': 'eNho5yRBEBxhGBtQRww9QirZsB66TrfFReG_CcteI1aCneT0ELGhYlRlC'
'tUkTRclIfuEPmNsNDPbLoLqqCVznFbvdB7x-Tl-m0l_eFTj2KiqwGqE9PZ'
'B9nNTwMVvH3VRRSLWACvPnSiwP8N5Usy-WRXS-V7TbpxIhvepTfE0NNo'
},
);
var keyStore = JsonWebKeyStore()..addKey(jwk);
// decrypt the payload
var payload = await jwe.getPayload(keyStore);
print('decrypted content: ${payload.stringContent}');
}
// create a JWE
void example4() async {
// create a builder
var builder = JsonWebEncryptionBuilder();
// set the content
builder.stringContent = 'This is my bigest secret';
// set some protected header
builder.setProtectedHeader('createdAt', DateTime.now().toIso8601String());
// add a key to encrypt the Content Encryption Key
var jwk = JsonWebKey.fromJson(
{
'kty': 'RSA',
'n': 'sXchDaQebHnPiGvyDOAT4saGEUetSyo9MKLOoWFsueri23bOdgWp4Dy1Wl'
'UzewbgBHod5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SYhG4EcL6FWbX5h9yuv'
'ngs4iLEFk6eALoUS4vIWEwcL4txw9LsWH_zKI-hwoReoP77cOdSL4AVcra'
'Hawlkpyd2TWjE5evgbhWtOxnZee3cXJBkAi64Ik6jZxbvk-RR3pEhnCs',
'dq': 'o_8V14SezckO6CNLKs_btPdFiO9_kC1DsuUTd2LAfIIVeMZ7jn1Gus_Ff'
'7B7IVx3p5KuBGOVF8L-qifLb6nQnLysgHDh132NDioZkhH7mI7hPG-PYE_'
'odApKdnqECHWw0J-F0JWnUd6D2B_1TvF9mXA2Qx-iGYn8OVV1Bsmp6qU',
'qi': 'eNho5yRBEBxhGBtQRww9QirZsB66TrfFReG_CcteI1aCneT0ELGhYlRlC'
'tUkTRclIfuEPmNsNDPbLoLqqCVznFbvdB7x-Tl-m0l_eFTj2KiqwGqE9PZ'
'B9nNTwMVvH3VRRSLWACvPnSiwP8N5Usy-WRXS-V7TbpxIhvepTfE0NNo'
},
);
builder.addRecipient(jwk, algorithm: 'RSA1_5');
// set the content encryption algorithm to use
builder.encryptionAlgorithm = 'A128CBC-HS256';
// build the jws
var jwe = builder.build();
// output the compact serialization
print('jwe compact serialization: ${jwe.toCompactSerialization()}');
// output the json serialization
print('jwe json serialization: ${jwe.toJson()}');
}
// decode and verify and validate a JWT
void example5() async {
var encoded = 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.'
'eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt'
'cGxlLmNvbS9pc19yb290Ijp0cnVlfQ.'
'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk';
// decode the jwt, note: this constructor can only be used for JWT inside JWS
// structures
var jwt = JsonWebToken.unverified(encoded);
// output the claims
print('claims: ${jwt.claims}');
// create key store to verify the signature
var keyStore = JsonWebKeyStore()
..addKey(JsonWebKey.fromJson({
'kty': 'oct',
'k':
'AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow'
}));
var verified = await jwt.verify(keyStore);
print('verified: $verified');
// alternatively, create and verify the JsonWebToken together, this is also
// applicable for JWT inside JWE
jwt = await JsonWebToken.decodeAndVerify(encoded, keyStore);
// validate the claims
var violations = jwt.claims.validate(issuer: Uri.parse('alice'));
print('violations: $violations');
}
// create a JWT
void example6() async {
var claims = JsonWebTokenClaims.fromJson({
'exp': Duration(hours: 4).inSeconds,
'aud':"live-tv",
'iat':DateTime.now().toString(),
});
// create a builder, decoding the JWT in a JWS, so using a
// JsonWebSignatureBuilder
var builder = JsonWebSignatureBuilder();
// set the content
builder.jsonContent = claims.toJson();
// add a key to sign, can only add one for JWT
builder.addRecipient(
JsonWebKey.fromJson({
'kty': 'RSA',
'kid':pkey,
}),
algorithm: 'HS256');
// build the jws
var jws = builder.build();
// output the compact serialization
print('jwt compact serialization: ${jws.toCompactSerialization()}');
}
// create a JWT, sign with RS512
void example7() async {
var claims = JsonWebTokenClaims.fromJson({
'exp': Duration(hours: 4).inSeconds,
'iss': 'alice',
});
// create a builder, decoding the JWT in a JWS, so using a
// JsonWebSignatureBuilder
var builder = JsonWebSignatureBuilder();
// set the content
builder.jsonContent = claims.toJson();
// add a key to sign, can only add one for JWT
var key = JsonWebKey.fromPem(File('example/jwtRS512.key').readAsStringSync());
builder.addRecipient(key, algorithm: 'RS512');
// build the jws
var jws = builder.build();
// output the compact serialization
print('jwt compact serialization: ${jws.toCompactSerialization()}');
}
// generate a key for use with ES256 signing
void example8() async {
var alg = JsonWebAlgorithm.getByName('ES256');
var key = alg.generateRandomKey();
print(JsonEncoder.withIndent(' ').convert(key));
final hash = utf8.encode('TEST');
var sig = key.sign(hash);
final valid = key.verify(hash, sig);
print('valid? $valid');
}

I tried each example at a time modifying each of those.Few of them said saying "Compact serialisation should have 3 parts",then I did a bit of research and realised that the token to be generated should have 3 parts.The other error in example 2 was that the JSONWebKey can't be signed.

There is another library I used and that was https://pub.dev/packages/corsac_jwt.

The code is below:

import 'package:corsac_jwt/corsac_jwt.dart';
//  ..setClaim('13', {'userId': 'xxxx'})
String pkey="sdfdsfdsfds";
void tokenGenerator() {
var builder = new JWTBuilder();
var token = builder
..audience="live-tv"
..issuedAt= new DateTime.now()
..expiresAt = new DateTime.now().add(new Duration(minutes: 3))
..getToken(); // returns token without signature
var signer = new JWTRsaSha256Signer(privateKey: pkey);
var signedToken = builder.getSignedToken(signer);
print("token");
print(signedToken); // prints encoded JWT
var stringToken = signedToken.toString();
var decodedToken = new JWT.parse(stringToken);
// Verify signature:
print(decodedToken.verify(signer)); // true
// Validate claims:
//  var validator = new JWTValidator() ;// uses DateTime.now() by default
//   // set claims you wish to validate
//  Set<String> errors = validator.validate(decodedToken);
//  print(errors); // (empty list)
}

But here I got the error invalid private key.If I changed it to public,I got invalid public key as well.

I honestly am I a very chaotic situation mentally with time running out to implement.My team mates are know only one thing I know only flutter only.

By the way the Java code we are trying to implement in flutter is given below.Basically what it does is it takes a StringKey,converts to a PrivateKey and then the token

import android.util.Log;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class RSAKeyGenerator {
private static PrivateKey getPrivateKey() throws GeneralSecurityException {
String pKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
KeyFactory kf = KeyFactory.getInstance("RSA");
byte[] decode;
decode = android.util.Base64.decode(pKey, android.util.Base64.DEFAULT);
PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(decode);
return kf.generatePrivate(keySpecPKCS8);
}
public static String getJwtToken() {
final long VALIDITY_MS = TimeUnit.MINUTES.toMillis(60);
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
Date exp = new Date(nowMillis + VALIDITY_MS);
PrivateKey privateKey = null;
try {
privateKey = getPrivateKey();
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
String jws = Jwts.builder()
.claim("version", "13")
.claim("user_id", "xxxxxxxxxxxxxxxxxxx")
.setIssuedAt(now)
.setExpiration(exp)
.signWith(privateKey, SignatureAlgorithm.RS256)
.setAudience("live-tv")
.compact();
Log.d("111__", jws);
SpUtil.Companion.getInstance().putString(J_TOKEN, jws);
return jws;
}
}

答案1

得分: 2

经过数小时的研究、试错以及与我的团队成员咨询,我得出了最终的结论。这有效。我之前犯的错误是我将 RSA 密钥传递为字符串,像这样:key="xxxxxxxxxxxx",但实际上它应该在以下格式中:

希望这能帮助到某些人

import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';

String token;

String dartJsonWebTokenGenerator() {
  Duration delay = new Duration(minutes: 300);
  final jwt = JWT(
    payload: {
      'version': '13',
      'user_id': 'xxxxxxxxxxxxxxxxx',
    },
    audience: 'live-tv',
  );

  // 对其进行签名(默认使用 HS256 算法)
  token = jwt.sign(PrivateKey('''
                  -----BEGIN RSA PRIVATE KEY-----
                  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7
                  ...
                  ...
                  ...
                  ...
                  ...
                  ...
                  ...
                  -----END RSA PRIVATE KEY-----
                  '''),
      algorithm: JWTAlgorithm.RS256, expiresIn: delay);
  print('已签名的令牌:$token\n');
  return token;
}

请注意,上面的代码为您提供了关于正确使用 RSA 密钥进行签名的示例。

英文:

After hours of research,trial and errors and consulting my team mates I have arrived at the final conclusion.This works.The mistake I was doing was the RSA key I was passing it as a string like key="xxxxxxxxxxxx",but it should be in the format below

Hope this helps someone

import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
String token;
String dartJsonWebTokenGenerator() {
Duration delay = new Duration(minutes: 300);
final jwt = JWT(
payload: {
'version': '13',
'user_id': 'xxxxxxxxxxxxxxxxx',
},
audience: 'live-tv',
);
// Sign it (default with HS256 algorithm)
token = jwt.sign(PrivateKey('''-----BEGIN RSA PRIVATE KEY-----
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IE0jVgbIw/rumFjxM/l4Dct8759FKZ4lkkKKCSXV5QMClQc
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxW
Qq/prxwXr/TUer7SzQXcfcMYdsjwougGeG6yYLZrT/FuOURoHDztEyOqZUeDU2zJ
Zdv6UGZfIsdHhcgGaE8B2l3ujkxIU6bGy3JRLETF80B9brHvIeKchpqom037LFuY
X7EKORMbp9R3jJ5eFG9TmTcCzXBtW6Aa2yH2RZzDNZ/1d+xhxEQzZVnyCEz/RhUI
Dd6EDQKCAQEAmpjDpt/xAH85F9UAvDw2RT9CJN016Dcf524nhppADlsHuBvk/lEJ
MrUoy9NW1pY+/UqC3XavKPS/L+z0+QX2zN2xA2o0PrLKjDFwhapFFX59zyRHZOpY
xRTTJ2vep8ChCl1+gSL1ZLYeMcyV72/peC0VHMYBo8uR0wtMzTy+4XYmni7jbr7B
96DYQBWjOBAvnBMQylr/FImHHNYsRKwlVJSUXUfe8ZT92T7bIOAVRr3ybJDofeTv
Hna+8lW5DzknQLGz8FESX6wBRCQY1Q6O+e/IqZecJPG+ly2g88yJ96zP4TrH7I5n
KREohbcwsctYbhL2UlcBE3QDTqdLnGJEowKCAQBwlBtw/BD5cefTcUB90XtuUpLG
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
moP4L4wBlad2aZYKnkZ87RZIa09wyf5hnPXQkQAHMRYxuaxvQUq/bSDO6JUbrGMp
J2LQgCreNAF7MsIDU2ijVHJNWp9m6LC1Osb1iMp/fZDy+hkAAHP5xDfDedwKmXLV
2kSdWPZebq1iIRyJ+BlbXAEgDMkp+k6mebq+kyH4+3odWvw8bRkmD/g1t/bS
-----END RSA PRIVATE KEY-----'''),
algorithm: JWTAlgorithm.RS256, expiresIn: delay);
print('Signed token: $token\n');
return token;
}

huangapple
  • 本文由 发表于 2020年8月24日 17:21:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/63558129.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定