What type of public key is this? - rsa

I have a public key, and the only way I know how to describe it to other programmer is that it's a xml public key. This description is not exactly the most defined.
<RSAKeyValue>
<Modulus>
uno9DsYcaZ1yAqY20nIM+YjYjjFsGx0DYm7lBGxbmVLLZTYc9MaI0Br+
8ElcuZVVNRmGeVBlkcHT3JpMDf/fiWSho6o0pRhQZmnG4RZtCWnGjFTV+
QWBYcuTGoQFKOtsrGqG16XwL2hPxqYW/7nzBVgAGe6myG3hMou8P4DSpjk=
</Modulus>
<Exponent>
AQAB
</Exponent>
</RSAKeyValue>
Is there another term for a key as such other than a generic term like "XML key"?
This key was generated by C#. Most likely with the command rsa.toxml()

Related

FallBack Mapping in Mapstruct

I am currently using mapstruct in my project. I have a target field 't1' which could be either mapped to source field 's1' or 's2', initially it should try to map the source field 's1' to target field 't1', in case it is null it should then fallback to source field 's2' for mapping it to the target field 't1'. And the source field objects in both cases are nested and would need some processing before it is mapped to the target. I've been looking around however I wasn't able to find any solution for this. Does Mapstruct support fallback Mapping? Below is an example, Here UserRequest is the target object and User is the source. In case I would like map id of the userRequest to user.address.postal primarily and in case it's null the id should be mapped to location.id of the overrideLocation. Can anyone please help me with this.
UserRequest{
String id;
}
User{
String name;
Address adress;
OverrideLocation location;
}
Address{
String postalCode;
}
OverrideLocation{
String id;
}
For now I've been using the AfterMapping in mapstruct to accomplish this. The primary mapping I specified as part of the #Mapping and the fallback mapping I've specified under AfterMapping. However I was wondering if there is a better way to deal with it. I looked into defaultValue and default expression as well, however I wasn't able to use it in this case

X509 Decoder tool based on Certificate schema file

I am looking for a tool which is capable to decode X509 Certificated where additional Extensions are also added according to a predefined schema.
Similar to this. I assume if it is the typical notation for the schema, then someone must have implemented a generic parser for that.
FooProtocol DEFINITIONS ::= BEGIN
FooQuestion ::= SEQUENCE {
trackingNumber INTEGER(0..199),
question IA5String
}
FooAnswer ::= SEQUENCE {
questionNumber INTEGER(10..20),
answer BOOLEAN
}
FooHistory ::= SEQUENCE {
questions SEQUENCE(SIZE(0..10)) OF FooQuestion,
answers SEQUENCE(SIZE(1..10)) OF FooAnswer,
anArray SEQUENCE(SIZE(100)) OF INTEGER(0..1000),
...
}
END
or real life example for a given Object ID extension
boot_seq := SEQUENCE
{
certType INTEGER, -- indicates certificate type
bootCore INTEGER, -- indicates the core in the device that needs to be booted
bootCoreOpts INTEGER, -- Configuration options for the core being booted
destAddr OCTET STRING, -- Load address
imageSize INTEGER -- image size
}
Those are the tools that are capable of compiling ASN.1 schemas into data bindings in a variety of languages and platforms: https://www.itu.int/en/ITU-T/asn1/Pages/Tools.aspx
Heimdal in its master branch has an open source ASN.1 compiler that understands a subset of X.681/X.682/X.683 extensions and can actually fully decode a Certificate, including every kind of Attribute, Extension, and OtherName declared in lib/asn1/rfc2459.asn1 (and you can add more, rebuild, and use it).
It also can transliterate DER to JSON (but it's not X.697 JER compliant), so you can run asn1_print /path/to/DER/file Certificate and you'll get a beautiful JSON representation of the complete certificate, including all the attributes, extensions, and otherName SAN types that are declared in lib/asn1/rfc2459.asn1.

Entity Framework error during update: field is required

I'm using EF 6.2.0, Code First from Database, in a .net 4.5.2 environment.
I have this DbSet:
<Table("Firebird.PLANT4")>
Partial Public Class PLANT4
<Key>
<DatabaseGenerated(DatabaseGeneratedOption.None)>
Public Property ID_PLANT4 As Integer
Public Property STATUS As Integer
<Required>
<StringLength(20)>
Public Property DESCRIPTION1 As String
Public Property COUNTER As Long
Public Property RESET_COUNTER As Integer
End Class
When I execute this code:
Using dbContext As New DbModel
dbContext.Database.Connection.ConnectionString = GetFbConnectionString()
dbContext.Database.Connection.Open()
Dim plant As PLANT4 = dbContext.PLANT4.Find(1)
plant.RESET_COUNTER = 1
dbContext.SaveChanges()
End Using
I get the error: "DESCRIPTION1 field is required".
The exception is throwing during SaveChanges.
I can't understand where the problem is, as if I watch "plant" in debug, all fields are there (ID_PLANT4 = 1 is an existing row), and DESCRIPTION1 in particular is not Nothing.
I can simply remove the "Required" attribute and it works, but the attribute is a consequence of the db column not allowing nulls, so I don't think this is the right way to go.
I can even add this line of code, just after the "Using" statement:
dbContext.Configuration.ValidateOnSaveEnabled = False
and it works, but again I don't think this is the right way to go.
What is the reason of this behavior?
Eventually I find that the problem is: field DESCRIPTION1 is populate by default with 20 spaces. It is not null, but it is a string formed only by spaces. For an unknown reason, during validation this string is treated by EF like null, and an exception is thrown because it's a required field.
"Required" attribute is not needed, but I generate my POCO classes by "Code First from Database", so if a VARCHAR field is declared as "not null" it is automatically generated with the "Required" attribute. Now I think it's better allowing nulls for VARCHAR columns.

How to handle DataAnnotation RequiredField(ErrorMessage...) using EntityTypeConfiguration

I have EF poco classproperty which has the DataAnnotatins. They include the FK, mandatory, maxlength conditions.
[Required(ErrorMessage = "Company name cannot be empty")]
[StringLength(128, ErrorMessage = "The CompanyName should be less than 128 characters or less.")]
[Index(IsUnique = true)]
public string CompanyName { get; set; }
I am trying to move all these into EntityTypeConfigurations and am struggling to move the ErrorMessages.
Can any one give me a pointer on how to get this done>
As you can read here, constraints configured by fluent mappings will by evaluated only in the context. They don't trickle through to the UI, as data annotations do (when used with the correct framework). So the EF team figured it wouldn't make sense to craft a user-friendly error message here. The validation will just throw a standard DbValidationError saying something like
The field Name must be a string or array type with a maximum length of '128'
So you need the annotations if you want your own custom messages.

Generate RSA keypair in perl efficently with custom PRNG

I would want to generate a public and private keypair, effciently (fast) in perl, and be able to input random data for myself.
With inputting random data, I of course mean, that the function requires lets say X random bits to generate a public/private keypair of Y bits, and I should be able to supply these X bits to the function.
So idially, the function should look like:
($private, $public) = genRSAkeypair($randomdata, 1024);
and $private then contains:
----BEGIN RSA PRIVATE KEY-----
....
----END ....
and $public contains
----BEGIN RSA PUBLIC and so on...
$randomdata is then just a string of random bits from any random generator. If $randomdata is consistent between instance1 and instance2, instance1 and instance2 should return the same public and private keys.
If you want to know what the use of this is, is that I plan to make a password-based RSA key generation system, without any need to store any keys anywhere. So the key is generated straight out from the password, by using SHA512 chained in a specific way to create static random data.
Of course, the same public and private key must be returned everytime the same password is entered in the system, else the system would be useless.
Any ideas?
I would try Crypt::OpenSSL::RSA, it seems to bind
directly to libssl