Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jean-Baptiste Kempf
libaacs
Commits
08d869c8
Commit
08d869c8
authored
Oct 08, 2013
by
npzacs
Browse files
Added aacs_get_device_binding_id() and aacs_get_device_nonce()
parent
61463b4f
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
08d869c8
- Added aacs_get_device_binding_id() and aacs_get_device_nonce()
- Fixed reading PMSN
- Dropped support for compile-time PATCHED_DRIVE flag.
- Bus encryption support
...
...
src/examples/aacs_info.c
View file @
08d869c8
...
...
@@ -112,6 +112,7 @@ int main (int argc, char **argv)
const
uint8_t
*
id
=
aacs_get_disc_id
(
aacs
);
const
uint8_t
*
pmsn
=
aacs_get_pmsn
(
aacs
);
const
int
bec
=
aacs_get_bus_encryption
(
aacs
);
const
uint8_t
*
binding_id
=
aacs_get_device_binding_id
(
aacs
);
printf
(
"Disc ID: %s
\n
"
,
id
?
_hex2str
(
id
,
20
)
:
"???"
);
printf
(
"VID : %s
\n
"
,
vid
?
_hex2str
(
vid
,
16
)
:
"???"
);
printf
(
"MKBv : %d
\n
"
,
aacs_get_mkb_version
(
aacs
));
...
...
@@ -119,6 +120,7 @@ int main (int argc, char **argv)
printf
(
"Bus encryption:
\n
"
);
printf
(
" Device support: %s
\n
"
,
(
bec
&
AACS_BUS_ENCRYPTION_CAPABLE
)
?
"yes"
:
"no"
);
printf
(
" Enabled in media: %s
\n
"
,
(
bec
&
AACS_BUS_ENCRYPTION_ENABLED
)
?
"yes"
:
"no"
);
printf
(
"Device binding ID: %s
\n
"
,
binding_id
?
_hex2str
(
binding_id
,
16
)
:
"???"
);
aacs_close
(
aacs
);
...
...
src/file/keydbcfg.c
View file @
08d869c8
...
...
@@ -550,6 +550,61 @@ void *cache_get_or_update(const char *type, const void *data, uint32_t *len, uin
return
cache_data
;
}
int
config_save
(
const
char
*
name
,
const
void
*
data
,
uint32_t
len
)
{
char
*
path
=
NULL
;
FILE
*
fp
=
_open_cfg_file_user
(
name
,
&
path
,
"w"
);
int
result
=
0
;
if
(
fp
)
{
if
(
fwrite
(
&
len
,
1
,
4
,
fp
)
==
4
&&
fwrite
(
data
,
1
,
len
,
fp
)
==
len
)
{
DEBUG
(
DBG_FILE
,
"Wrote %d bytes to %s
\n
"
,
len
+
4
,
path
);
result
=
1
;
}
else
{
DEBUG
(
DBG_FILE
|
DBG_CRIT
,
"Error writing to %s
\n
"
,
path
);
}
fclose
(
fp
);
}
X_FREE
(
path
);
return
result
;
}
int
config_get
(
const
char
*
name
,
uint32_t
*
len
,
void
*
buf
)
{
char
*
path
=
NULL
;
FILE
*
fp
=
_open_cfg_file_user
(
name
,
&
path
,
"r"
);
int
result
=
0
;
uint32_t
size
=
*
len
;
*
len
=
0
;
if
(
fp
)
{
DEBUG
(
DBG_FILE
,
"Reading %s
\n
"
,
path
);
if
(
fread
(
len
,
1
,
4
,
fp
)
==
4
&&
(
size
<=
*
len
)
&&
(
!
buf
||
fread
(
buf
,
1
,
*
len
,
fp
)
==
*
len
))
{
DEBUG
(
DBG_FILE
,
"Read %d bytes from %s
\n
"
,
4
+
(
buf
?
*
len
:
0
),
path
);
result
=
1
;
}
else
{
DEBUG
(
DBG_FILE
|
DBG_CRIT
,
"Error reading from %s
\n
"
,
path
);
}
fclose
(
fp
);
}
X_FREE
(
path
);
return
result
;
}
static
char
*
_find_config_file
(
void
)
{
static
const
char
cfg_file_name
[]
=
CFG_FILE_NAME
;
...
...
src/file/keydbcfg.h
View file @
08d869c8
...
...
@@ -131,4 +131,7 @@ AACS_PRIVATE int cache_remove(const char *name);
AACS_PRIVATE
void
*
cache_get_or_update
(
const
char
*
type
,
const
void
*
data
,
uint32_t
*
len
,
uint32_t
version
);
AACS_PRIVATE
int
config_get
(
const
char
*
name
,
uint32_t
*
len
,
void
*
buf
);
/* use buf=NULL to get size */
AACS_PRIVATE
int
config_save
(
const
char
*
name
,
const
void
*
data
,
uint32_t
len
);
#endif
src/libaacs/aacs.c
View file @
08d869c8
...
...
@@ -70,6 +70,10 @@ struct aacs {
int
bee
;
/* bus encryption enabled flag in content certificate */
int
bec
;
/* bus encryption capable flag in drive certificate */
uint8_t
read_data_key
[
16
];
/* AACS Online (BD-J) */
uint8_t
device_nonce
[
16
];
uint8_t
device_binding_id
[
16
];
};
static
const
uint8_t
empty_key
[]
=
"
\x00\x00\x00\x00\x00\x00\x00\x00
"
...
...
@@ -1056,6 +1060,31 @@ const uint8_t *aacs_get_pmsn(AACS *aacs)
return
aacs
->
pmsn
;
}
const
uint8_t
*
aacs_get_device_binding_id
(
AACS
*
aacs
)
{
/* Device binding ID is used to encrypt online content.
* It needs to be cached so that downloaded content can be played later.
*/
static
const
char
config_file_name
[]
=
"device_binding_id"
;
uint32_t
len
=
sizeof
(
aacs
->
device_binding_id
);
DEBUG
(
DBG_AACS
,
"reading device binding id
\n
"
);
if
(
!
config_get
(
config_file_name
,
&
len
,
aacs
->
device_binding_id
)
||
len
!=
sizeof
(
aacs
->
device_binding_id
))
{
DEBUG
(
DBG_AACS
,
"creating device binding id
\n
"
);
crypto_create_nonce
(
aacs
->
device_binding_id
,
sizeof
(
aacs
->
device_binding_id
));
config_save
(
config_file_name
,
aacs
->
device_binding_id
,
sizeof
(
aacs
->
device_binding_id
));
}
return
aacs
->
device_binding_id
;
}
const
uint8_t
*
aacs_get_device_nonce
(
AACS
*
aacs
)
{
DEBUG
(
DBG_AACS
,
"creating device nonce
\n
"
);
crypto_create_nonce
(
aacs
->
device_nonce
,
sizeof
(
aacs
->
device_nonce
));
return
aacs
->
device_nonce
;
}
static
AACS_RL_ENTRY
*
_get_rl
(
const
char
*
type
,
int
*
num_records
,
int
*
mkbv
)
{
uint32_t
len
,
version
;
...
...
src/libaacs/aacs.h
View file @
08d869c8
...
...
@@ -52,6 +52,10 @@ AACS_PUBLIC const uint8_t *aacs_get_disc_id(AACS *aacs);
AACS_PUBLIC
const
uint8_t
*
aacs_get_vid
(
AACS
*
aacs
);
/* may fail even if disc can be decrypted */
AACS_PUBLIC
const
uint8_t
*
aacs_get_pmsn
(
AACS
*
aacs
);
/* may fail even if disc can be decrypted */
/* AACS Online */
AACS_PUBLIC
const
uint8_t
*
aacs_get_device_binding_id
(
AACS
*
aacs
);
AACS_PUBLIC
const
uint8_t
*
aacs_get_device_nonce
(
AACS
*
aacs
);
/* revocation lists */
typedef
struct
{
uint16_t
range
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment