I need read 10 byte in fileName and save it into bitLevel
My code:
PHP:
test = 0;
byte[] bitLevel = new byte[10];
string fileName = "levels\\";
switch(iChap){
case 1: fileName += "beginner.dat";
break;
case 2: fileName += "normal.dat";
break;
case 3: fileName += "intermediate.dat";
break;
case 4: fileName += "expert.dat";
break;
}
using(FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
fileStream.Seek((iLevel - 1) * 10, SeekOrigin.Begin);
fileStream.Read(bitLevel, 0,10);
test = 1;
}
but bitLevel is empty
It seem it's not into codes under using, because I set test = 1; but it = 0;
can anybody help me?
//sorry my bad english
Use IsolatedStorageFile & IsolatedStorageFileStream instead of FileStream.
sensboston said:
Use IsolatedStorageFile & IsolatedStorageFileStream instead of FileStream.
Click to expand...
Click to collapse
is that ok?
can you show me demo code?
Code:
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
try
{
using (IsolatedStorageFileStream inStream = new IsolatedStorageFileStream(fileName, FileMode.Open, isf))
{
byte[] buffer = new byte[10];
int numRead = inStream.Read(buffer, 0, 10);
Debug.Assert (numRead == 10);
}
}
catch (Exception e)
{
Debug.WriteLine(e.Message + "\n" + e.StackTrace);
}
But this code for ISF only; I don't really know where are your files located (as resources or may be content). You should understand what are you trying to read first
If you added these files as a content to your project, you should read 'em from the TitleContainer
Code:
using (var inStream = TitleContainer.OpenStream(fileName))
using (StreamReader streamReader = new StreamReader(inStream))
... and so on...
Just wanted to share some knowledge here.
The main code responsable for the random MAC wifi adress with the newer BCMDHD wifi driver is mainly due to a small peace of code :
eeprom-wifi-mac.c in /tf101-kernel_whatever/arch/arm/mach-tegra.
code snippet:
Code:
#include <linux/i2c/at24.h>
#include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/slab.h>
#define EEPROM_LEN 32
static char wifi_mac[] = "ff:ff:ff:ff:ff:ff";
static ssize_t show_addr_sysfs(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%s\n", wifi_mac);
}
DEVICE_ATTR(addr, 0444, show_addr_sysfs, NULL);
static struct attribute *wifi_mac_addr_attributes[] = {
&dev_attr_addr.attr,
NULL
};
static const struct attribute_group wifi_mac_addr_group = {
.attrs = wifi_mac_addr_attributes,
};
int create_sys_fs(void)
{
int ret = -1;
static struct kobject *reg_kobj;
reg_kobj = kobject_create_and_add("wifi_mac_addr", kernel_kobj);
if (!reg_kobj)
return -ENOMEM;
ret = sysfs_create_group(reg_kobj, &wifi_mac_addr_group);
if (ret < 0) {
kobject_put(reg_kobj);
return ret;
}
return ret;
}
void get_mac_addr(struct memory_accessor *mem_acc, void *context)
{
char *mac_addr;
int ret = 0;
off_t offset = (off_t)context;
mac_addr = kzalloc(sizeof(char)*EEPROM_LEN, GFP_ATOMIC);
if (!mac_addr) {
pr_err("no memory to allocate");
return;
}
/* Read MAC addr from EEPROM */
ret = mem_acc->read(mem_acc, mac_addr, offset, EEPROM_LEN);
if (ret == EEPROM_LEN) {
pr_err("Read MAC addr from EEPROM: %pM\n", (mac_addr+19));
sprintf(wifi_mac, "%02x:%02x:%02x:%02x:%02x:%02x",
*(mac_addr+19), *(mac_addr+20), *(mac_addr+21),
*(mac_addr+22), *(mac_addr+23), *(mac_addr+24));
} else
pr_err("Error reading MAC addr from EEPROM\n");
create_sys_fs();
}
Now we need a code monkey to do some dirty work and give us a new algorithm we can apply to the kernel for reading out / creating the MAC adress in another way. Maybe create a new sysfs interface to be able to change the MAC adress to whatever we like in userspace mode, e.g. per app.
Remember: This is a dev thread. Please do only post development-related stuff in here. Any help is appreciated. If you just want to say 'thanks', well, you know where the corresponding button is, don't ya ?
I don't understand what positive use a random MAC could be?
Sent from my Transformer TF101 using xda app-developers app
Probably the easiest way would be to strace wifimacwriter on ICS. It must call something in the kernel to get the MAC, or run some ioctls. Anyway, it's not self contained, so if we figure out how it works, we can write it ourselves, in kernel space.
Hello Guys,Its My First Post In Forum I am Sorry If I made Any Mistake..
Actually i am tring to creat a php for android app before sometime i dont have any idea about how to view source code but thanks to xda-forum developer ...now i have knowledge to view source code of android app
Now Coming to point ..
Android App Contain Many java File In classes.dex Folder .... i have checked every file but i didnt get any web link
here is web links means ....
example-if we have any website like www . somesite . com
then if will view its soruce code then we will get like; -
action-register.php
something like this
i am searching the links in apk so please guys help me to find out it
Here is i am show off some codes of my apk file
Code:
import a.a.a.a.f;
import a.a.a.a.p;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.location.Location;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.aj;
import android.util.SparseArray;
import com.android.volley.toolbox.m;
import com.android.volley.u;
import com.appsflyer.AppsFlyerLib;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.am;
import com.google.android.gms.common.api.an;
import com.google.android.gms.common.api.aq;
import com.google.android.gms.common.api.ar;
import com.google.android.gms.common.api.i;
import com.google.android.gms.common.api.j;
import com.google.android.gms.common.api.l;
import free.bux.d.b;
import free.bux.e.g;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class FreeBuzzApp
extends Application
implements j, l
{
public static final String a = FreeBuzzApp.class.getSimpleName();
private static FreeBuzzApp c;
protected com.google.android.gms.common.api.h b;
private u d;
private m e;
private g f;
private Handler g;
private HashMap h = new HashMap();
public static FreeBuzzApp a()
{
return c;
}
public static boolean a(String paramString)
{
Iterator localIterator = c.getPackageManager().getInstalledApplications(0).iterator();
do
{
if (!localIterator.hasNext()) {
break;
}
} while (!((ApplicationInfo)localIterator.next()).packageName.equals(paramString));
for (boolean bool = true;; bool = false) {
return bool;
}
}
private void c()
{
Object localObject1 = null;
boolean bool1 = true;
for (;;)
{
i locali;
try
{
locali = new i(this);
locali.j.add(this);
locali.k.add(this);
com.google.android.gms.common.api.a locala = com.google.android.gms.location.h.a;
locali.c.put(locala, null);
locali.a.addAll(locala.c);
boolean bool2;
if (!locali.c.isEmpty())
{
bool2 = bool1;
com.google.android.gms.common.internal.ap.b(bool2, "must call addApi() to add at least one API");
if (locali.e < 0) {
continue;
}
am localam = am.a(locali.d);
localObject1 = new com.google.android.gms.common.api.y(locali.b.getApplicationContext(), locali.h, locali.a(), locali.i, locali.c, locali.j, locali.k, locali.e, -1);
int k = locali.e;
l locall2 = locali.g;
com.google.android.gms.common.internal.ap.a(localObject1, "GoogleApiClient instance cannot be null");
if (localam.c.indexOfKey(k) < 0)
{
com.google.android.gms.common.internal.ap.a(bool1, "Already managing a GoogleApiClient with id " + k);
an localan = new an(localam, k, (com.google.android.gms.common.api.h)localObject1, locall2);
localam.c.put(k, localan);
if ((localam.a) && (!localam.b)) {
((com.google.android.gms.common.api.h)localObject1).a();
}
this.b = ((com.google.android.gms.common.api.h)localObject1);
}
}
else
{
bool2 = false;
continue;
}
bool1 = false;
continue;
if (locali.f < 0) {
break label497;
}
com.google.android.gms.common.api.ap localap = com.google.android.gms.common.api.ap.a(locali.d);
int i = locali.f;
if (localap.D != null)
{
aq localaq = localap.b(i);
if (localaq != null) {
localObject1 = localaq.i;
}
}
if (localObject1 == null) {
localObject1 = new com.google.android.gms.common.api.y(locali.b.getApplicationContext(), locali.h, locali.a(), locali.i, locali.c, locali.j, locali.k, -1, locali.f);
}
int j = locali.f;
l locall1 = locali.g;
com.google.android.gms.common.internal.ap.a(localObject1, "GoogleApiClient instance cannot be null");
if (localap.a.indexOfKey(j) < 0)
{
bool3 = bool1;
com.google.android.gms.common.internal.ap.a(bool3, "Already managing a GoogleApiClient with id " + j);
ar localar = new ar((com.google.android.gms.common.api.h)localObject1, locall1, (byte)0);
localap.a.put(j, localar);
if (localap.D == null) {
continue;
}
android.support.v4.app.al.a = false;
localap.j().a(j, localap);
continue;
}
boolean bool3 = false;
}
finally {}
continue;
label497:
localObject1 = new com.google.android.gms.common.api.y(locali.b, locali.h, locali.a(), locali.i, locali.c, locali.j, locali.k, -1, -1);
}
}
/* Error */
public final com.google.android.gms.analytics.u a(h paramh)
{
// Byte code:
// 0: aload_0
// 1: monitorenter
// 2: aload_0
// 3: getfield 42 free/bux/FreeBuzzApp:h Ljava/util/HashMap;
// 6: aload_1
// 7: invokevirtual 262 java/util/HashMap:containsKey (Ljava/lang/Object;)Z
// 10: ifne +43 -> 53
// 13: aload_0
// 14: invokestatic 267 com/google/android/gms/analytics/l:a (Landroid/content/Context;)Lcom/google/android/gms/analytics/l;
// 17: astore 4
// 19: aload_1
// 20: getstatic 272 free/bux/h:a Lfree/bux/h;
// 23: if_acmpne +46 -> 69
// 26: aload 4
// 28: ldc_w 274
// 31: invokevirtual 277 com/google/android/gms/analytics/l:a (Ljava/lang/String;)Lcom/google/android/gms/analytics/u;
// 34: astore 7
// 36: aload 7
// 38: iconst_1
// 39: putfield 280 com/google/android/gms/analytics/u:a Z
// 42: aload_0
// 43: getfield 42 free/bux/FreeBuzzApp:h Ljava/util/HashMap;
// 46: aload_1
// 47: aload 7
// 49: invokevirtual 281 java/util/HashMap:put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
// 52: pop
// 53: aload_0
// 54: getfield 42 free/bux/FreeBuzzApp:h Ljava/util/HashMap;
// 57: aload_1
// 58: invokevirtual 285 java/util/HashMap:get (Ljava/lang/Object;)Ljava/lang/Object;
// 61: checkcast 279 com/google/android/gms/analytics/u
// 64: astore_3
// 65: aload_0
// 66: monitorexit
// 67: aload_3
// 68: areturn
// 69: getstatic 287 free/bux/h:b Lfree/bux/h;
// 72: pop
// 73: aload 4
// 75: invokevirtual 290 com/google/android/gms/analytics/l:b ()Lcom/google/android/gms/analytics/u;
// 78: astore 6
// 80: aload 6
// 82: astore 7
// 84: goto -48 -> 36
// 87: astore_2
// 88: aload_0
// 89: monitorexit
// 90: aload_2
// 91: athrow
// Local variable table:
// start length slot name signature
// 0 92 0 this FreeBuzzApp
// 0 92 1 paramh h
// 87 4 2 localObject1 Object
// 64 4 3 localu1 com.google.android.gms.analytics.u
// 17 57 4 locall com.google.android.gms.analytics.l
// 78 3 6 localu2 com.google.android.gms.analytics.u
// 34 49 7 localObject2 Object
// Exception table:
// from to target type
// 2 65 87 finally
// 69 80 87 finally
}
public final void a(int paramInt)
{
this.b.a();
}
public final void a(Bundle paramBundle)
{
Location localLocation = com.google.android.gms.location.h.b.a(this.b);
if (localLocation != null)
{
free.bux.e.d.b(this, "latitude", String.valueOf(localLocation.getLatitude()));
free.bux.e.d.b(this, "longitude", String.valueOf(localLocation.getLongitude()));
new StringBuilder("startLocationUpdates--> User lat ").append(String.valueOf(localLocation.getLatitude()));
}
}
public final void a(ConnectionResult paramConnectionResult)
{
new StringBuilder("Connection failed: ConnectionResult.getErrorCode() = ").append(paramConnectionResult.c);
}
public final m b()
{
if (this.d == null) {
this.d = com.android.volley.toolbox.y.a(getApplicationContext());
}
if (this.e == null)
{
if (this.f == null) {
this.f = new g();
}
this.e = new m(this.d, this.f);
}
return this.e;
}
public void onCreate()
{
super.onCreate();
p[] arrayOfp = new p[1];
arrayOfp[0] = new com.a.a.a();
f.a(this, arrayOfp);
if (Build.VERSION.SDK_INT >= 9)
{
boolean bool = getSharedPreferences("free.bux_preferences", 0).getBoolean("APP_FLYER_TRACKING", true);
AppsFlyerLib.setAppsFlyerKey("4ffriSMaSjMyjrv5EDKJEB");
if (bool)
{
AppsFlyerLib.sendTracking(getApplicationContext());
SharedPreferences.Editor localEditor = getSharedPreferences("free.bux_preferences", 0).edit();
localEditor.putBoolean("APP_FLYER_TRACKING", false);
localEditor.commit();
}
}
try
{
PackageInfo localPackageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
b.a = "Freebuzz/" + localPackageInfo.versionCode + "(Android" + Build.VERSION.RELEASE + ";" + Build.MODEL + " Build /" + Build.FINGERPRINT + ";" + Locale.getDefault() + ";)";
new StringBuilder("http header is ").append(b.a);
c();
c = this;
this.g = new Handler();
a(h.b);
this.b.a();
return;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
for (;;)
{
new StringBuilder("Cannot find package details with name ").append(getPackageName());
}
}
}
public void onLowMemory()
{
super.onLowMemory();
}
public void onTerminate()
{
super.onTerminate();
}
}
So, I decided I want to put Kali-Linux on my samsung s3 neo device, and I succeeded after hard work and a lots of research... Now I had another problem, that my built-in chipset does not support aircrack-ng, so i decided to work around it, and use a wireless usb adapter.
what i did is modifying the kernel, to be able to support some of the wireless devices... the point where i got stuck is at compiling the new-made kernel... basically i followed the following guide:
PHP:
http://forum.xda-developers.com/showthread.php?t=2338179
and i got stuck at the final section of the compiling segment...
So here is my error.
arch/arm/crypto/sha512_neon_glue.c: In function 'sha512_neon_update':
arch/arm/crypto/sha512_neon_glue.c:144:3: warning: implicit declaration of function 'crypto_sha512_update' [-Wimplicit-function-declaration]
error, forbidden warning: sha512_neon_glue.c:144
scripts/Makefile.build:307: recipe for target 'arch/arm/crypto/sha512_neon_glue.o' failed
make[1]: *** [arch/arm/crypto/sha512_neon_glue.o] Error 1
Makefile:950: recipe for target 'arch/arm/crypto' failed
make: *** [arch/arm/crypto] Error 2
Click to expand...
Click to collapse
so, first of all I have a question, where exactly do i put "KCONFIG_CFLAGS += -w" in the code of the Makefile, and if it would solve the error? according to the guide it should ignore errors that the compiler makes.
2nd question right under the code lines.
Makefile:
PHP:
https://github.com/CyanogenMod/android_kernel_samsung_s3ve3g/blob/cm-12.1/Makefile
Couldn't post it here, too long.
Second question, in case the first solution would not work, if i wanted to edit the problematic file, so it would see the declared functions, how do i do that?
NOTE: the error is in line 144
(will be marked with "------->")
Code:
*
* Glue code for the SHA512 Secure Hash Algorithm assembly implementation
* using NEON instructions.
*
* Copyright © 2014 Jussi Kivilinna <[email protected]>
*
* This file is based on sha512_ssse3_glue.c:
* Copyright (C) 2013 Intel Corporation
* Author: Tim Chen <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#include <crypto/internal/hash.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/cryptohash.h>
#include <linux/types.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <asm/byteorder.h>
#include <asm/simd.h>
#include <asm/neon.h>
static const u64 sha512_k[] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
0xd807aa98a3030242ULL, 0x12835b0145706fbeULL,
0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL,
0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL,
0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL,
0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL,
0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL,
0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
0xd192e819d6ef5218ULL, 0xd69906245565a910ULL,
0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL,
0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL,
0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL,
0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL,
0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
0x28db77f523047d84ULL, 0x32caab7b40c72493ULL,
0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
};
asmlinkage void sha512_transform_neon(u64 *digest, const void *data,
const u64 k[], unsigned int num_blks);
static int sha512_neon_init(struct shash_desc *desc)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
sctx->state[0] = SHA512_H0;
sctx->state[1] = SHA512_H1;
sctx->state[2] = SHA512_H2;
sctx->state[3] = SHA512_H3;
sctx->state[4] = SHA512_H4;
sctx->state[5] = SHA512_H5;
sctx->state[6] = SHA512_H6;
sctx->state[7] = SHA512_H7;
sctx->count[0] = sctx->count[1] = 0;
return 0;
}
static int __sha512_neon_update(struct shash_desc *desc, const u8 *data,
unsigned int len, unsigned int partial)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int done = 0;
sctx->count[0] += len;
if (sctx->count[0] < len)
sctx->count[1]++;
if (partial) {
done = SHA512_BLOCK_SIZE - partial;
memcpy(sctx->buf + partial, data, done);
sha512_transform_neon(sctx->state, sctx->buf, sha512_k, 1);
}
if (len - done >= SHA512_BLOCK_SIZE) {
const unsigned int rounds = (len - done) / SHA512_BLOCK_SIZE;
sha512_transform_neon(sctx->state, data + done, sha512_k,
rounds);
done += rounds * SHA512_BLOCK_SIZE;
}
memcpy(sctx->buf, data + done, len - done);
return 0;
}
static int sha512_neon_update(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int partial = sctx->count[0] % SHA512_BLOCK_SIZE;
int res;
/* Handle the fast case right here */
if (partial + len < SHA512_BLOCK_SIZE) {
sctx->count[0] += len;
if (sctx->count[0] < len)
sctx->count[1]++;
memcpy(sctx->buf + partial, data, len);
return 0;
}
if (!may_use_simd()) {
------------> res = crypto_sha512_update(desc, data, len);
} else {
kernel_neon_begin();
res = __sha512_neon_update(desc, data, len, partial);
kernel_neon_end();
}
return res;
}
/* Add padding and return the message digest. */
static int sha512_neon_final(struct shash_desc *desc, u8 *out)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int i, index, padlen;
__be64 *dst = (__be64 *)out;
__be64 bits[2];
static const u8 padding[SHA512_BLOCK_SIZE] = { 0x80, };
/* save number of bits */
bits[1] = cpu_to_be64(sctx->count[0] << 3);
bits[0] = cpu_to_be64(sctx->count[1] << 3 | sctx->count[0] >> 61);
/* Pad out to 112 mod 128 and append length */
index = sctx->count[0] & 0x7f;
padlen = (index < 112) ? (112 - index) : ((128+112) - index);
if (!may_use_simd()) {
crypto_sha512_update(desc, padding, padlen);
crypto_sha512_update(desc, (const u8 *)&bits, sizeof(bits));
} else {
kernel_neon_begin();
/* We need to fill a whole block for __sha512_neon_update() */
if (padlen <= 112) {
sctx->count[0] += padlen;
if (sctx->count[0] < padlen)
sctx->count[1]++;
memcpy(sctx->buf + index, padding, padlen);
} else {
__sha512_neon_update(desc, padding, padlen, index);
}
__sha512_neon_update(desc, (const u8 *)&bits,
sizeof(bits), 112);
kernel_neon_end();
}
/* Store state in digest */
for (i = 0; i < 8; i++)
dst[i] = cpu_to_be64(sctx->state[i]);
/* Wipe context */
memset(sctx, 0, sizeof(*sctx));
return 0;
}
static int sha512_neon_export(struct shash_desc *desc, void *out)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
memcpy(out, sctx, sizeof(*sctx));
return 0;
}
static int sha512_neon_import(struct shash_desc *desc, const void *in)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
memcpy(sctx, in, sizeof(*sctx));
return 0;
}
static int sha384_neon_init(struct shash_desc *desc)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
sctx->state[0] = SHA384_H0;
sctx->state[1] = SHA384_H1;
sctx->state[2] = SHA384_H2;
sctx->state[3] = SHA384_H3;
sctx->state[4] = SHA384_H4;
sctx->state[5] = SHA384_H5;
sctx->state[6] = SHA384_H6;
sctx->state[7] = SHA384_H7;
sctx->count[0] = sctx->count[1] = 0;
return 0;
}
static int sha384_neon_final(struct shash_desc *desc, u8 *hash)
{
u8 D[SHA512_DIGEST_SIZE];
sha512_neon_final(desc, D);
memcpy(hash, D, SHA384_DIGEST_SIZE);
memset(D, 0, SHA512_DIGEST_SIZE);
return 0;
}
static struct shash_alg algs[] = { {
.digestsize = SHA512_DIGEST_SIZE,
.init = sha512_neon_init,
.update = sha512_neon_update,
.final = sha512_neon_final,
.export = sha512_neon_export,
.import = sha512_neon_import,
.descsize = sizeof(struct sha512_state),
.statesize = sizeof(struct sha512_state),
.base = {
.cra_name = "sha512",
.cra_driver_name = "sha512-neon",
.cra_priority = 250,
.cra_flags = CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize = SHA512_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
}, {
.digestsize = SHA384_DIGEST_SIZE,
.init = sha384_neon_init,
.update = sha512_neon_update,
.final = sha384_neon_final,
.export = sha512_neon_export,
.import = sha512_neon_import,
.descsize = sizeof(struct sha512_state),
.statesize = sizeof(struct sha512_state),
.base = {
.cra_name = "sha384",
.cra_driver_name = "sha384-neon",
.cra_priority = 250,
.cra_flags = CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize = SHA384_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
} };
static int __init sha512_neon_mod_init(void)
{
if (!cpu_has_neon())
return -ENODEV;
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
static void __exit sha512_neon_mod_fini(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
module_init(sha512_neon_mod_init);
module_exit(sha512_neon_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA512 Secure Hash Algorithm, NEON accelerated");
MODULE_ALIAS("sha512");
MODULE_ALIAS("sha384");
Please help me I will be very thankful.
(NOTE: I am not a developer, and I wish I was, or at least i'm ought to be so please explain carefully your solutions since I'm not familiar with any coding language, and for me, reaching this stage of the kernel compiling was time consuming and my only tools were my logic and the internet). thanks in advance for any help i can get i wish it will work so i can move on in learning kali better!